首页 > 其他分享 >2022河南省赛

2022河南省赛

时间:2022-10-07 22:11:56浏览次数:69  
标签:constexpr 河南省 ++ long cin int 2022 using

链接:
https://codeforces.com/gym/103941

A

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

void solve() {
  int n;
  cin >> n;
  if (n > 10) {
    cout << -1 << '\n';
  } else if (n == 1) {
    cout << 1;
  } else if (n == 2) {
    cout << 10;
  } else {
    cout << 10;
    for (int i = 2; i <= n - 1; i++) {
      cout << i;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

D

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

using d64 = long double;
using Point = pair<double, double>;

const double Pi = acos(-1);

#define x first
#define y second

void solve() {
  int n;
  cin >> n;
  vector<Point> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].y;
  }
  Point center;
  cin >> center.x >> center.y;
  vector<Point> b(4);
  for (int i = 0; i < 4; i++) {
    cin >> b[i].x >> b[i].y;
  }
  vector<d64> d(2);
  for (int i = 0; i < 2; i++) {
    int I = i * 2, J = i * 2 + 1;
    d[i] = fabs(
      (d64) (b[I].y - b[J].y) * center.x - (d64) (b[I].x - b[J].x) * center.y + (d64) b[I].x * b[J].y - (d64) b[I].y * b[J].x
    ) / hypot<d64>(b[I].x - b[J].x, b[I].y - b[J].y);
  }
  double ans = 0;
  vector<array<double, 2>> c;
  auto push = [&](double l, double r, double now) {
    if (l <= now && now <= r) {
      c.push_back({0, r - now});
      c.push_back({360 + l - now, 360});
      return;
    }
    if (now <= l) {
      c.push_back({l - now, r - now});
      return;
    }
    if (now >= r) {
      c.push_back({360 + l - now, 360 + r - now});
      return;
    }
  };
  for (int i = 0; i < n; i++) {
    d64 dis = hypot<d64>(a[i].x - center.x, a[i].y - center.y);
    double angle = atan2(a[i].y - center.y, a[i].x - center.x) * 180 / Pi;
    if (angle < 0) {
      angle += 360;
    }
    if (dis > d[0]) {
      double angle2 = acos(d[0] / dis) * 180 / Pi;
      push(180 - angle2, 180 + angle2, angle);
    }
    if (dis > d[1]) {
      double angle2 = acos(d[1] / dis) * 180 / Pi;
      push(0, angle2, angle);
      push(360 - angle2, 360, angle);
    }
  }
  sort(c.begin(), c.end());
  double pre = 0;
  for (auto [u, v] : c) {
    if (u >= pre) {
      ans += v - u;
      pre = v;
    } else if (v > pre) {
      ans += v - pre;
      pre = v;
    }
  }
  cout << 360 - ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

A和cf一个题差不多

链接:
https://codeforces.com/contest/1430/problem/E

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

template <typename T>
class Fenwick {
 public:
  int n;
  vector<T> tree;
  Fenwick(const int &n) : n(n), tree(n) {}
  inline void modify(int pos, T x) {
    for ( ; pos <= n; pos += pos & -pos) {
      tree[pos - 1] += x;
    }
  }
  inline T get(int pos) {
    T res = 0;
    for ( ; pos > 0; pos -= pos & -pos) {
      res += tree[pos - 1];
    }
    return res;
  }
  inline T sum(int l, int r) { // (l, r]
    return get(r) - get(l);
  }
};

constexpr int N = 26;

int cnt[N];
int half[N];

void solve() {
  int n;
  string s;
  cin >> n >> s;
  s = " " + s;
  Fenwick<int> f(n);
  vector<vector<int>> pos(26);
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) {
    int num = s[i] - 'a';
    pos[num].push_back(i);
  }
  i64 ans = 0;
  for (int i = 1; i <= n; i++) {
    int num = s[i] - 'a';
    p[n - i + 1] = pos[num].back();
    pos[num].pop_back();
  }
  for (int i = n; i >= 1; i--) {
    ans += f.get(p[i]);
    f.modify(p[i], 1);
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

E

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

void solve() {
  int n;
  string s;
  cin >> n >> s;
  map<char, char> mp;
  bool ok1 = 0, ok2 = 0, ok3 = 0;
  string ans;
  for (int i = 0; i < n; i++) {
    mp[s[i]]++;
    if (ok1 == 0 && mp[s[i]] == 5) {
      ok1 = 1;
      mp.clear();
      for (int j = 0; j < 5; j++)
        ans.push_back(s[i]);
    } else if (ok2 == 0 && ok1 == 1 && mp[s[i]] == 7) {
      ok2 = 1;mp.clear();
      for (int j = 0; j < 7; j++)
        ans.push_back(s[i]);
    } else if (ok3 == 0 && ok1 == 1 && ok2 == 1 && mp[s[i]] == 5) {
      ok3 = 1;
      for (int j = 0; j < 5; j++)
        ans.push_back(s[i]);
      break;
    }
  }
  if (ok3) {
    cout << ans << '\n';
  } else {
    cout << "none" << '\n';
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

F

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

void solve() {
  int n;
  cin >> n;
  if (n == 2 || n == 4) {
    cout << -1 << '\n';
  } else if (n % 2 == 0) {
    cout << n / 2 << '\n';
    for (int i = 1; i <= n / 2 - 1; i++) {
      cout << i << ' ';
    }
    cout << n / 2 + 1;
    cout << '\n';
  } else {
    cout << (n + 1) / 2 << '\n';
    for (int i = 1; i <= n; i += 2) {
      cout << i << ' ';
    }
    cout << '\n';
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

G

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  int I, J, l, r, p;
  cin >> I >> J >> l >> r >> p;
  int ans = 0;
  for (int j = 0; j < m; j++) {
    bool ok = 1;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == '0') {
        ok = 0;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

H

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

constexpr int N = 1E5;

bool vis[2][N + 10];

void solve() {
  int m, sy, ty;
  cin >> m >> sy >> ty;
  sy--;
  ty--;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < m; j++) {
      vis[i][j] = 0;
    }
  }
  vector<vector<char>> a(2, vector<char>(m + 1));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  bool ok = 0;
  function<void(int, int, int, int)> dfs = [&](int x, int y, int dx, int dy) {
    if (ok) {
      return;
    }
    if (x == 2 && y == ty) {
      ok = 1;
      return;
    }
    if (x > 1 || x < 0) {
      return;
    }
    if (y > m - 1 || y < 0) {
      return;
    }
    if (vis[x][y]) {
      return;
    }
    vis[x][y] = 1;
    if (a[x][y] == 'I') {
      dfs(x + dx, y + dy, dx, dy);
    } else if (a[x][y] == 'L') {
      if (dx == 0 && dy == 1) {
        dfs(x + 1, y, 1, 0);
        dfs(x - 1, y, -1, 0);
      } else if (dx == 1 && dy == 0) {
        dfs(x, y + 1, 0, +1);
        dfs(x, y - 1, 0, -1);
      } else if (dx == 0 && dy == -1) {
        dfs(x + 1, y, +1, 0);
        dfs(x - 1, y, -1, 0);
      } else if (dx == -1 && dy == 0) {
        dfs(x, y + 1, 0, +1);
        dfs(x, y - 1, 0, -1);
      }      
    } 
    vis[x][y] = 0;
  }; 
  dfs(0, sy, 1, 0);
  cout << (ok ? "YES" : "NO") << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

I

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

//constexpr int M = 998244353;
//constexpr int M = 1000000007;

constexpr int N = 9;

int id[3][N][N];
int pos[3][N][N];

// 0 -> x
// 1 -> y
// 2 -> z

vector<array<int, 7>> a;

// [0]->time
// [1]->id
// [2]->in/out
// [3]->people
// [4]->x
// [5]->y
// [6]->z

void solve() {
  int n, m, h;
  cin >> n >> m >> h;
  int k;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int t, x, y, z;
    cin >> t >> x >> y >> z;
    if (t == 0) { // x
      id[t][y][z] = i;
      pos[t][y][z] = x;
    } else if (t == 1) { // y
      id[t][x][z] = i;
      pos[t][x][z] = y;
    } else { // z
      id[t][x][y] = i;
      pos[t][x][y] = z;
    }
  }

  // (fx, fy, fz) 
  //      -> 
  // (tx, fy, fz) 
  //      -> 
  // (tx, ty, fz) 
  //      -> 
  // (tx, ty, tz)

  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int t, fx, fy, fz, tx, ty, tz;
    cin >> t >> fx >> fy >> fz >> tx >> ty >> tz;
    auto get = [&](int people, int t0, int type, int A, int B, int &S, int T, int L) {
      int POS = pos[type][A][B];
      int ID = id[type][A][B];
      int t1 = 0;
      if (S >= POS) {
        t1 = S - POS;
      } else {
        t1 = L + S - POS;
      }
      while (t1 < t0) {
        t1 += L;
      }
      a.push_back({t1, ID, 1, people, fx, fy, fz});
      int t2 = t1;
      if (T > S) {
        t2 += T - S;
      } else {
        t2 += L + T - S;
      }
      S = T;
      a.push_back({t2, ID, 0, people, fx, fy, fz});
      return t2 + 1;
    };
    if (fx != tx) {
      t = get(i, t, 0, fy, fz, fx, tx, n);
    }
    if (fy != ty) {
      t = get(i, t, 1, fx, fz, fy, ty, m);
    }
    if (fz != tz) {
      t = get(i, t, 2, fx, fy, fz, tz, h);
    }
  }
  sort(a.begin(), a.end());
  int asz = a.size();
  for (int i = 0; i < asz; i++) {
    cout << "[" <<
    a[i][0] << "s] Person " <<
    a[i][3] << " " << 
    (a[i][2] ? "IN" : "OUT") << " Elevator " << 
    a[i][1] << " at (" << 
    a[i][4] << ", " << 
    a[i][5] << ", " << 
    a[i][6] << ")\n";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(6);
  int tt = 1;
  //cin >> tt;
  for (int _ = 1; _ <= tt; _++) {
    solve();
  }
  return 0;
}

标签:constexpr,河南省,++,long,cin,int,2022,using
From: https://www.cnblogs.com/kiddingma/p/16767328.html

相关文章

  • 2022.10.7第三次组会记录
    团队:集农广益小组地点:桃园食堂时间:晚上九点参与人:全体人员组会内容摘要:分析项目具体架构和功能,讨论数据流图的设计要求组会主要内容:1.分析讨论用户的具体功能:发帖、......
  • 2022上海省赛
    A#include"bits/stdc++.h"usingnamespacestd;usingi64=longlong;//constexprintM=998244353;//constexprintM=1000000007;boolno[10];intcnt[1......
  • 2022-2023-1学期 20221417魏正一 《计算机基础与程序设计》第6周学习总结
    第六周学习目标·Polya如何解决问题·简单类型与组合类型·复合数据结构·查找与排序算法·算法复杂度·递归·代码安全学习资源·教材·阅读「反作弊」:任何时......
  • 2022/10/7 T3 boss挑战
    题目地址题目大意:给你敌人的生命值,你的生命值、愤怒值、蓝值,愤怒值可以在普攻造成伤害的同时回复,生命和蓝值可以喝药回,愤怒值和蓝值可以放大招造成伤害,每回合你先选一种行......
  • 逆向工程核心原理——DLL注入 虽然原版是针对win7 32位的 我自己使用vs2022 在win11 6
    逆向工程核心原理——第二十三章 先说我自己本机win1164位上注入记事本的效果:  虽然弹出一个窗口。但是还是成功了:   生成了index.html文件  ......
  • 2022-2023-1 20221407
    进制转换班级......
  • 2022.10.7
    ACM。结果不是很好。一开始的节奏是很好的,但从A题调不出来开始就乱了。每个人再自己的题上都有深入思考,但对别人的情况不了解,所以讨论的效率实际不高,而且很容易被套进死胡......
  • 2022牛客国庆集训派对day6 A(极大矩阵计数)
    2022牛客国庆集训派对day6A(极大矩阵计数)A-All-oneMatrices_2022牛客国庆集训派对day6(nowcoder.com)题目求可以构成给出的01矩阵的全1极大矩阵数目思路悬线法可......
  • 【闲话】2022.10.07
    发现似乎我妈登上博客园了那我是不是该收敛点啊总之今天考了场试啊密码还是我的某中文网名全拼。还是相对论:只要大家都挂了那我就没有挂————bikuhiku看......
  • 2022-10-07-学习内容
    1.设置文本字体大小1.1activity_text_size.xml<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"......