제출 #967612

#제출 시각아이디문제언어결과실행 시간메모리
967612Yang8onSimple game (IZhO17_game)C++14
100 / 100
50 ms9052 KiB
#include <bits/stdc++.h> #define Y8o "Simple game" #define maxn 1000005 #define ll long long #define pii pair<int, int> #define gb(i, j) ((i >> j) & 1) using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } const int mx = maxn - 5; int n, Q; int a[maxn]; int bit[maxn]; void update(int x, int val) { while(x <= mx) bit[x] += val, x += (x & -x); } int get(int x) { int best = 0; while(x) best += bit[x], x -= (x & -x); return best; } void update(int l, int r, int val) { if(l > r) swap(l, r); update(l, +val), update(r + 1, -val); } void solve() { cin >> n >> Q; for(int i = 1; i <= n; i ++) cin >> a[i]; for(int i = 1; i <= n - 1; i ++) update(a[i], a[i + 1], +1); for(int i = 1, id, pos, H; i <= Q; i ++) { cin >> id; if(id == 1) { cin >> pos >> H; if(pos < n) { update(a[pos], a[pos + 1], -1); update(H, a[pos + 1], +1); } if(pos > 1) { update(a[pos - 1], a[pos], -1); update(H, a[pos - 1], +1); } a[pos] = H; } else { cin >> H; cout << get(H) << '\n'; } } } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

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

game.cpp: In function 'void iof()':
game.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...