Submission #587473

#TimeUsernameProblemLanguageResultExecution timeMemory
587473NekoRollyRMQ (NOI17_rmq)C++17
67 / 100
1087 ms2248 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5+4; int n,q; int a[N],p[N]; int L[N],R[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q; for (int i=0; i<n; i++) R[i] = n-1, p[i] = -1; for (int i=0,l,r,x; i<q; i++){ cin >> l >> r >> x; for (int j=l; j<=r; j++) a[j] = max(a[j], x); L[x] = max(L[x], l), R[x] = min(R[x], r); } for (int i=0; i<n; i++){ int pos = -1; for (int j=L[i]; j<=R[i]; j++) if (a[j] <= i && p[j] == -1) pos = j; if (pos == -1){ for (int i=0; i<n; i++) p[i] = -1; break; } p[pos] = i; } for (int i=0; i<n; i++) cout << p[i] << " "; cout << "\n"; return 0; }

Compilation message (stderr)

rmq.cpp: In function 'int main()':
rmq.cpp:31:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   31 |  for (int i=0; i<n; i++) cout << p[i] << " "; cout << "\n";
      |  ^~~
rmq.cpp:31:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   31 |  for (int i=0; i<n; i++) cout << p[i] << " "; cout << "\n";
      |                                               ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...