Submission #76688160


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//using mint=modint998244353;
void solve(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>a(m);
    rep(i,m)cin>>a[i].first>>a[i].second;
    sort(a.begin(),a.end());
    vector<int>ans(n,1);
    set<int>s,u;
    int t=0,ma=-1;
    rep(i,n){
        if(t<m){
            while(i==a[t].first-1){
            if(ma<i){
                s=u;
                for(int j=i;j<a[t].second;j++){
                    ans[j]=j-i+1;
                    s.insert(j-i+1);
                }
            }
            else{
                if(a[t].second>ma){
                    int co=1;
                    for(int j=ma+1;j<a[t].second;j++){
                        while(s.count(co))co++;
                        ans[j]=co;
                        s.insert(co);
                    }
                }
            }
            if(a[t].second>ma)ma=a[t].second-1;
            t++;
            if(t==m)break;
        }
    }
    s.erase(ans[i]);
    }
    rep(i,n)cout<<ans[i]<<' ';
    cout<<endl;
}
int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t=1;
    cin>>t;
    while(t--)solve();
}

Submission Info

Submission Time
Task A - Colorful Intervals
User itoito1234
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1300 Byte
Status AC
Exec Time 1541 ms
Memory 15056 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 30
Set Name Test Cases
Sample 01_sample_01.txt
All 01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 03_rand_1_01.txt, 03_rand_1_02.txt, 03_rand_1_03.txt, 03_rand_1_04.txt, 03_rand_1_05.txt, 04_rand_2_01.txt, 04_rand_2_02.txt, 04_rand_2_03.txt, 04_rand_2_04.txt, 04_rand_2_05.txt, 05_rand_3_01.txt, 05_rand_3_02.txt, 05_rand_3_03.txt, 05_rand_3_04.txt, 05_rand_3_05.txt, 05_rand_3_06.txt, 05_rand_3_07.txt, 05_rand_3_08.txt, 05_rand_3_09.txt, 05_rand_3_10.txt, 06_other_01.txt, 06_other_02.txt, 06_other_03.txt, 06_other_04.txt, 06_other_05.txt, 06_other_06.txt, 06_other_07.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 1 ms 3604 KiB
02_small_01.txt AC 35 ms 3540 KiB
02_small_02.txt AC 37 ms 3464 KiB
03_rand_1_01.txt AC 50 ms 3732 KiB
03_rand_1_02.txt AC 50 ms 3648 KiB
03_rand_1_03.txt AC 50 ms 3616 KiB
03_rand_1_04.txt AC 50 ms 3584 KiB
03_rand_1_05.txt AC 49 ms 3576 KiB
04_rand_2_01.txt AC 87 ms 3796 KiB
04_rand_2_02.txt AC 96 ms 3800 KiB
04_rand_2_03.txt AC 119 ms 3720 KiB
04_rand_2_04.txt AC 89 ms 3856 KiB
04_rand_2_05.txt AC 85 ms 3748 KiB
05_rand_3_01.txt AC 513 ms 9712 KiB
05_rand_3_02.txt AC 792 ms 6104 KiB
05_rand_3_03.txt AC 1541 ms 10316 KiB
05_rand_3_04.txt AC 1004 ms 6832 KiB
05_rand_3_05.txt AC 404 ms 12264 KiB
05_rand_3_06.txt AC 38 ms 5164 KiB
05_rand_3_07.txt AC 559 ms 5352 KiB
05_rand_3_08.txt AC 22 ms 4484 KiB
05_rand_3_09.txt AC 303 ms 12752 KiB
05_rand_3_10.txt AC 1037 ms 9900 KiB
06_other_01.txt AC 59 ms 3464 KiB
06_other_02.txt AC 49 ms 13392 KiB
06_other_03.txt AC 208 ms 15056 KiB
06_other_04.txt AC 27 ms 5680 KiB
06_other_05.txt AC 30 ms 5608 KiB
06_other_06.txt AC 19 ms 5584 KiB
06_other_07.txt AC 63 ms 14936 KiB