結果
問題 |
No.2080 Simple Nim Query
|
ユーザー |
|
提出日時 | 2022-09-25 22:39:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,280 bytes |
コンパイル時間 | 1,705 ms |
コンパイル使用メモリ | 196,760 KB |
最終ジャッジ日時 | 2025-02-07 15:36:45 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i=0; i<n; i++) #define pb push_back typedef long long ll; struct BIT { int size; vector<int> node; BIT(int n) { size = n; node.resize(n+1); } void add(int i, int x) { i++; while (i<=size) { node[i] += x; i += i&(-i); } } int acc(int i) { int s = 0; while (i>0) { s += node[i]; i -= i&(-i); } return s; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, Q; cin >> N >> Q; int A[N]; rep(i, N) cin >> A[i]; BIT bit(N); rep(i, N) bit.add(i, A[i]); while (Q--) { int T, X, Y; cin >> T >> X >> Y; if (T==1) { X--; bit.add(X, -A[X]); A[X] = Y; bit.add(X, A[X]); } else { int l = 0; int r = Y-X+1; while (l<=r) { int m = (l+r)/2; int c = bit.acc(Y)-bit.acc(Y-m); if (c==m) l = m+1; else r = m-1; } if (r%2==0) cout << "F" << endl; else cout << "S" << endl; } } }