# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
674510 |
2022-12-24T16:16:12 Z |
sugartheanh |
RMQ (NOI17_rmq) |
C++14 |
|
2 ms |
340 KB |
#include <bits/stdc++.h>
#define ll long long
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define fi first
#define se second
#define oo 1e18
#define bit(x,i) (((x)>>(i))&1)
using namespace std;
const int MOD = 1e9 + 7;
const int N = 5e3 + 5;
int n,q,l,r,a,c[N],ans[N];
bool vs[N];
int main()
{
#ifndef ONLINE_JUDGE
freopen("new.inp","r",stdin);
freopen("new.out","w",stdout);
#endif // ONLINE_JUDGE
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>q;
while(q--)
{
cin>>l>>r>>a;
fo(j,l,r)
c[j] = max(c[j], a);
}
fo(i,0,n-1)
vs[i] = 0,ans[i] = -1;
// fo(i,0,n-1)
// cout<<c[i]<<' ';
// cout<<'\n';
fo(i,0,n-1)
{
fo(j,0,n-1)
{
if(j >= c[i] && !vs[j])
{
ans[i] = j;
vs[j] = 1;
break;
}
}
}
fo(i,0,n-1)
if(ans[i] == -1)
{
fo(j,1,n)
cout<<-1<<' ';
return 0;
}
fo(i,0,n-1)
cout<<ans[i]<<' ';
}
Compilation message
rmq.cpp: In function 'int main()':
rmq.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | freopen("new.inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
rmq.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen("new.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |