제출 #984418

#제출 시각아이디문제언어결과실행 시간메모리
984418saayan007다리 (APIO19_bridges)C++17
0 / 100
32 ms3156 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i) #define repd(i, a, b) for(int (i) = (a); i >= (b); --i) #define em emplace #define eb emplace_back #define pi pair<int, int> #define fr first #define sc second #define mp make_pair const char nl = '\n'; const int mod = 1e9 + 7; const int inf = 1e17; struct SGT { int n, m; vector<int> a; SGT() {} SGT(int N, int wt[]) { /* n = 1; while(n < N + 1) n *= 2; */ /* a.resize(2*n, -inf); */ /* m = N - 1; */ /* rep(i, 1, N - 1) { */ /* a[i + n] = wt[i]; */ /* } */ /* repd(i, n - 1, 1) calc(i); */ n = N - 1; a.resize(n + 1); rep(i, 1, n - 1) a[i] = wt[i]; } void mod(int x, int v) { /* x += n; */ /* a[x] = v; */ /* for(x /= 2; x > 0; x /= 2) calc(x); */ } void calc(int i) { /* if(i >= n) a[i] = min(a[2*i], a[2*i + 1]); */ } /* int left(int x, int lx, int rx, int pos, int val) { */ /* if(rx < pos) return n; */ /* if(a[x] >= val) return n; */ /* int d = (lx + rx) / 2; */ /* if(d < pos) return left(2*x + 1, d + 1, rx, pos, val); */ /* int ans = left(2*x, lx, d, pos, val); */ /* if(ans < n) return ans; */ /* return left(2*x + 1, d + 1, rx, pos, val); */ /* } */ int left(int pos, int val) { // first i >= pos with a[i] < val while(pos < n && a[pos] >= val) ++pos; return pos; /* return min(m + 1, left(1, 0, n - 1, pos, val)); */ } /* int right(int x, int lx, int rx, int pos, int val) { */ /* if(lx > pos) return 0; */ /* if(a[x] >= val) return 0; */ /* int d = (lx + rx) / 2; */ /* if(pos < d + 1) return right(2*x, lx, d, pos, val); */ /* int ans = right(2*x + 1, d + 1, rx, pos, val); */ /* if(ans > 0) return ans; */ /* return right(2*x, lx, d, pos, val); */ /* } */ int right(int pos, int val) { // first i <= pos with a[i] < val /* return max(1ll, right(1, 0, n - 1, pos, val)); */ while(pos > 0 && a[pos] >= val) --pos; return pos; } }; #warning constants according to subtask const int N = 5e4L + 10; const int M = 1e5L + 10; int n, m, q; int ed[M][3]; int wt[N]; SGT sgt; void modify(int b, int r) { wt[b] = r; sgt.mod(b, r); } void query(int s, int w) { int r = sgt.left(s, w); int l = sgt.right(s - 1, w); cout << r - l << nl; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; rep(i, 1, m) { int u, v, d; cin >> u >> v >> d; assert(u == i); assert(v == i + 1); wt[u] = d; } sgt = SGT(n + 1, wt); cin >> q; rep(i, 1, q) { int t; cin >> t; if(t == 1) { int b, r; cin >> b >> r; modify(b, r); } else { int s, w; cin >> s >> w; query(s, w); } } }

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

bridges.cpp:81:2: warning: #warning constants according to subtask [-Wcpp]
   81 | #warning constants according to subtask
      |  ^~~~~~~
bridges.cpp: In constructor 'SGT::SGT(long long int, long long int*)':
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:35:9: note: in expansion of macro 'rep'
   35 |         rep(i, 1, n - 1) a[i] = wt[i];
      |         ^~~
bridges.cpp: In function 'int32_t main()':
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:105:5: note: in expansion of macro 'rep'
  105 |     rep(i, 1, m) {
      |     ^~~
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:116:5: note: in expansion of macro 'rep'
  116 |     rep(i, 1, q) {
      |     ^~~
#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...