QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#136644 | #238. Distinct Values | nameless_story# | 100 ✓ | 132ms | 4468kb | C++20 | 770b | 2023-08-09 09:39:23 | 2023-08-09 09:39:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
priority_queue<int,vector<int>,greater<int>> q;
int n,m; cin>>n>>m;
for (int i=1;i<=n;++i) q.push(i);
vector r(n+1,n+1);
vector a(n+1,0);
for (int i=1;i<=m;++i){
int x,y; cin>>x>>y;
r[y]=min(r[y],x);
}
r[n]=min(r[n],n);
for (int i=n-1;i>=1;--i){
r[i]=min(r[i],i);
r[i]=min(r[i+1],r[i]);
}
int j=1;
for (int i=1;i<=n;++i){
int l=r[i];
while (j<l){
q.push(a[j]);
++j;
}
a[i]=q.top();
q.pop();
cout<<a[i]<<" \n"[i==n];
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int T; cin>>T;
while (T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 132ms
memory: 4468kb
input:
11116 10 2 5 5 5 6 10 1 7 10 10 1 2 6 10 1 2 5 10 1 6 7 10 2 8 9 7 10 10 2 1 4 6 10 10 4 8 8 10 10 3 6 1 5 10 3 8 8 10 10 8 10 10 4 6 10 1 5 2 6 1 2 10 3 4 4 4 8 4 8 10 4 1 5 1 2 5 5 2 4 10 4 2 5 9 10 6 7 2 4 10 1 5 6 10 4 10 10 8 10 2 5 10 10 10 1 1 2 10 4 7 8 5 6 7 9 10 10 10 4 3 7 6 6 8 10 3 4 10...
output:
1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 3 4 1 1 2 3 4 5 1 1 1 1 1 1 2 3 4 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 3 4 1 2 3 4 1 1 2 3 4 5 1 2 3 4 5 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 2 3 4 5 1 2 3 4 5 1 1 1 1 2 3 4 5 1 1 1 2 3 4 5 1 1 1 1 1 1 1 2 3 4 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 2 3 4 1 1 1 2 3 ...
result:
ok 11116 lines