Submission #1084715

#TimeUsernameProblemLanguageResultExecution timeMemory
1084715KerimBridges (APIO19_bridges)C++17
0 / 100
43 ms856 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 5e4+5; struct node{ int val, l, r; } seg[N<<2]; int v[N]; void build(int x, int l, int r){ seg[x].l = l, seg[x].r = r; if(l == r){ seg[x].val = v[l]; return; } int mid = (l+r)>>1; build(x<<1, l, mid); build(x<<1|1, mid+1, r); seg[x].val = min(seg[x<<1].val, seg[x<<1|1].val); } void update(int x, int k, int u){ if(seg[x].l == seg[x].r){ seg[x].val = u; return; } int mid = (seg[x].l+seg[x].r)>>1; if(k <= mid) update(x<<1, k, u); else update(x<<1|1, k, u); seg[x].val = min(seg[x<<1].val, seg[x<<1|1].val); } int query(int x, int l, int r){ if(l > r) return 0; if(seg[x].l == l and seg[x].r == r) return seg[x].val; int mid = (seg[x].l+seg[x].r)>>1; if(r <= mid) return query(x<<1, l, r); else if(l > mid) return query(x<<1|1, l, r); else return min(query(x<<1, l, mid), query(x<<1|1, mid+1, r)); } int main(){ // freopen("file.txt", "r", stdin); int n, m; scanf("%d%d", &n, &m); for(int i = 1; i <= m; ++i){ int a, b, x; scanf("%d%d%d", &a, &b, &x); v[i] = x; } //build(1, 1, n); int q; scanf("%d", &q); while(q--){ int op; scanf("%d", &op); if(op == 1){ int b, r; scanf("%d%d", &b, &r); //update(1, b, r); v[b] = r; continue; } // op = 2 int s, w; scanf("%d%d", &s, &w); // int l = 1, r = s, ans = 1e9; // while(l <= r){ // int mid = (l+r)>>1; // int mn = query(1, mid, s-1); // if(mn < w) // l = mid+1; // else // r = mid-1, ans = mid; // } // int ans1 = 0; // l = s, r = m; // while(l <= r){ // int mid = (l+r)>>1; // int mn = query(1, s, mid); // if(mn < w) // r = mid-1; // else // l = mid+1, ans1 = mid; // } // printf("%d\n", answer+1); int ans = 1, ans1 = 0; for(int i = s-1; i >= 1; --i){ if(v[i] < w){ ans = i+1; break; } if(i == 1) ans = 1; } for(int i = s; i <= m; ++i){ if(v[i] < w){ ans1 = i; break; } if(i == m) ans1 = m+1; } printf("%d\n", ans1-ans+1); } return 0; }

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:65:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
bridges.cpp:68:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         scanf("%d%d%d", &a, &b, &x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
bridges.cpp:76:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         scanf("%d", &op);
      |         ~~~~~^~~~~~~~~~~
bridges.cpp:79:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |             scanf("%d%d", &b, &r);
      |             ~~~~~^~~~~~~~~~~~~~~~
bridges.cpp:86:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         scanf("%d%d", &s, &w);
      |         ~~~~~^~~~~~~~~~~~~~~~
#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...