Submission #1084712

#TimeUsernameProblemLanguageResultExecution timeMemory
1084712KerimBridges (APIO19_bridges)C++17
16 / 100
841 ms3424 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; int v[N]; int main(){ int n, m; scanf("%d%d", &n, &m); assert(m+1 == n); for(int i = 1; i <= n-1; ++i){ int a, b, x; scanf("%d%d%d", &a, &b, &x); v[i] = x; } int q; scanf("%d", &q); while(q--){ int op; scanf("%d", &op); if(op == 1){ int b, r; scanf("%d%d", &b, &r); v[b] = r; continue; } int s, w; scanf("%d%d", &s, &w); int l = 1, r = n; for(int i = s-1; i >= 1; i--) if(v[i] < w){ l = i+1; break; } for(int i = s; i < n; i++) if(v[i] < w){ r = i; break; } printf("%d\n", r-l+1); } return 0; }

Compilation message (stderr)

bridges.cpp: In function 'int main()':
bridges.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
bridges.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d%d%d", &a, &b, &x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
bridges.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
bridges.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d", &op);
      |         ~~~~~^~~~~~~~~~~
bridges.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf("%d%d", &b, &r);
      |             ~~~~~^~~~~~~~~~~~~~~~
bridges.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         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...