首页 > 其他分享 >AtCoder Beginner Contest 258

AtCoder Beginner Contest 258

时间:2022-09-20 12:55:40浏览次数:92  
标签:AtCoder Beginner int cin long ++ 258 ans using

AtCoder Beginner Contest 258

Link

A - When?

模拟即可.

点击查看代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n; scanf("%d", &n);
  int x = 21, y = 0;
  x += n / 60, y += n % 60;
  printf("%02d:%02d", x, y);
  return 0;
}

B - Number Box

模拟即可.

点击查看代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }

int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n; cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i ++ ) {
    cin >> s[i];
  }

  array<int, 2> pos = {0, 0};
  for(int i = 0; i < n; i ++ ) {
    for(int j = 0; j < s[i].size(); j ++ ) {
      if(s[pos[0]][pos[1]] < s[i][j]) {
        pos = {i, j};
      }
    }
  }


  auto dfs = [&] (array<int, 2> p) {
    string ans;
    for(int i = 0; i < 8; i ++ ) {
      int x = p[0], y = p[1];
      string res; res.push_back(s[p[0]][p[1]]);
      for(int j = 0; j < n - 1; j ++ ) {
        x += dx[i], y += dy[i];
        x = (x + n) % n, y = (y + n) % n;
        res.push_back(s[x][y]);
      }
      ans = max(ans, res);
    }
    return ans;

  };

  string ans(n, '0');
  for(int i = 0; i < n; i ++ ) {
    for(int j = 0; j < n; j ++ ) {
      if(s[pos[0]][pos[1]] == s[i][j]) {
        ans = max(ans, dfs({i, j}));
      }
    }
  }
  cout << ans << "\n";

  return 0;
}

C - Rotation

模拟即可.

点击查看代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include <debugger>
#else
#define debug(...) 42
#endif

template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, q; cin >> n >> q;
  string s; cin >> s;
  int st = 0;
  while(q -- ) {
    int op; cin >> op;
    if(op == 1) {
      int x; cin >> x;
      st -= x;
      st = (st % n + n) % n;
    } else {
      int x; cin >> x;
      cout << s[(st + x - 1 + n) % n] << "\n";
    }
  }
  return 0;
}

D - Trophy

模拟即可.

点击查看代码
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, x; cin >> n >> x;
  ll ans = INT64_MAX;
  vector<array<int, 2> > a(n);
  for(auto &[x, y]: a) cin >> x >> y; 
  ll now = 0;
  for(int i = 0; i < n && i < x; i ++ ) {
    now += a[i][0] + a[i][1];
    ll ret = now;
    int cnt = x - i - 1;
    chkmin(ans, ret + 1ll * a[i][1] * cnt);
  }
  cout << ans << "\n";
  return 0;
}

E - Packing Potatoes

标签:AtCoder,Beginner,int,cin,long,++,258,ans,using
From: https://www.cnblogs.com/c972937/p/abc258.html

相关文章

  • AtCoder Beginner Contest 269
    比赛链接A模拟即可。点击查看代码#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;inta,b,c,d;signedmain(){ cin>>a>>b>>c>>d; cout<<(......
  • Atcoder 题集
    Atcoder题集E-Lucky7Battle博弈论,对抗性搜索,记忆化搜索#include<bits/stdc++.h>usingnamespacestd;stringt,x;intn;intf[200010][7];intdfs(inti,intr){......
  • AtCoder Regular Contest 148 C Lights Out on Tree
    挺好的一道题,简单写一下题解吧。首先有挺多很naive的结论:每个节点按两遍等于没按。熄灭所有的灯只有一种方案。其实将灯熄灭的方案无非就是从上往下dfs,如果当前灯......
  • AtCoder Beginner Contest 268
    E-ChineseRestaurant(Three-StarVersion)假设旋转\(x\)次时,\(n\)个人失望值的总和为\(c_x\),那么只要能求出\(c_x,0\lex<n\)就可以包含所有情况,然后再取......
  • AtCoder Beginner Contest 269 (A-F)题解
    A-AnywayTakahashi这里我还是关了ll的C开了忘了关害的F多了一发罚时#include<bits/stdc++.h>usingnamespacestd;constintN=3e5+10;constintM=9982443......
  • AtCoder Beginner Contest 269
    咕咕咕咕咕。F-NumberedChecker首先矩形容斥,把一个询问拆分成4个询问。现在只需要解决:左上角为\((1,1)\),右下角为\((x,y)\)的矩形区域和这一问题。把列数为奇......
  • AtCoder Beginner Contest 267 题解
    只会\(A\simG\)主观难度:\(A<B<C<E<D<F<G<Ex\)A-Saturday分别对周一到周五判断即可。#include<bits/stdc++.h>usingnamespacestd;inlineintread(){int......
  • AtCoder Beginner Contest 262(D-E)
    D-IHateNon-integerNumber题意:一个长度为n的数组,选择其中的x项,问其中有多少种选择,这x项的和可以被选择的数目整除,比如,选择3个数,和为6,那么6/3=2,就可以被整除。题解:......
  • AtCoder Regular Contest 147
    ProblemA题目大意:由N个正整数组成的序列,我们可以从中取出任意长短序列进行如下操作:序列中(最大值maxn%最小值minn=A),如果A为0则删除maxn,否则用A替换,询问要使得整个序......
  • AtCoder做题记录
    AtCoder大乱炖AtCoder乱做AtCoder随便草ARC147ARC147C发现这个式子当所有\(x_i\)趋近于某一个值时答案比较优,于是可以发现这是一个近似单谷函数,用二分+随机化/特......