제출 #800371

#제출 시각아이디문제언어결과실행 시간메모리
800371PixelCat식물 비교 (IOI20_plants)C++14
5 / 100
71 ms21748 KiB
#include "plants.h" #ifdef NYAOWO #include "grader.cpp" #endif #include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(), x.end() #define sz(x) ((int)x.size()) #define eb emplace_back // #define int LL using namespace std; using i32 = int32_t; using LL = long long; using pii = pair<int, int>; // const int MAXN = 300; // vector<int> adj[MAXN + 10]; // int vis[MAXN + 10]; // bitset<MAXN + 10> tal[MAXN + 10]; // void dp(int n) { // if(vis[n]) return; // vis[n] = 1; // tal[n].reset(); // for(auto &i:adj[n]) { // dp(i); // tal[n] |= tal[i]; // tal[n][i] = 1; // } // } const int MAXN = 200'000; const int MAXLG = 20; int n; int sp[MAXLG + 5][MAXN + 10]; int dist(int s, int t) { if(s <= t) return t - s; else return t - s + n; } void init(int __k, vector<int> __r) { n = sz(__r); For(i, 0, n - 1) sp[0][i] = (1 << __r[i]); For(j, 1, MAXLG - 1) For(i, 0, n - 1) { sp[j][i] = sp[j - 1][i]; if(i + (1 << (j - 1)) < n) sp[j][i] |= sp[j - 1][i + (1 << j - 1)]; } // int n = sz(r); // vector<int> alive(n, 1); // For(_, 1, n) { // int idx = -1; // vector<int> ids; // For(i, 0, n - 1) if(alive[i]) { // int c2 = k - 1; // For(j, 1, k - 1) { // if(alive[(i + j) % n]) { // c2--; // } // } // if(c2 == r[i]) ids.eb(i); // } // For(i, 1, sz(ids)) { // if(sz(ids) == 1 || dist(ids[i - 1], ids[i % sz(ids)], n) >= k) { // idx = ids[i % sz(ids)]; // break; // } // } // // for(auto &i:ids) cerr << i << " "; // // cerr << "\n"; // assert(idx >= 0); // // cerr << idx << "\n"; // // For(i, 0, n - 1) cerr << r[i] << " \n"[i == n - 1]; // For(i, n - k + 1, n - 1) { // int id = (idx + i) % n; // if(alive[id]) { // adj[id].eb(idx); // } // } // alive[idx] = 0; // } // memset(vis, 0, sizeof(vis)); // For(i, 0, n - 1) dp(i); } int qry(int l, int r) { if(l <= r) { int k = __lg(r - l + 1); return sp[k][l] | sp[k][r - (1 << k) + 1]; } return qry(l, n - 1) | qry(0, r); } int compare_plants(int x, int y) { int m1 = qry(x, y - 1); if(m1 != 3) { if(m1 == 1) return 1; return -1; } int m2 = qry(y, (x + n - 1) % n); if(m2 != 3) { if(m2 == 1) return -1; return 1; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:54:70: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   54 |         if(i + (1 << (j - 1)) < n) sp[j][i] |= sp[j - 1][i + (1 << j - 1)];
      |                                                                    ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...