Submission #76688918


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct nb{int x,y;}a[200010];
bool cmp(nb u,nb v){return u.x<v.x;}
int T,n,m,h,t,b[200010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--){
		cin>>n>>m;h=1;t=0;set<int>c;
		for(int i=1;i<=n;i++)c.insert(i),b[i]=0;
		for(int i=1;i<=m;i++)cin>>a[i].x>>a[i].y;
		sort(a+1,a+m+1,cmp);
		for(int i=1;i<=m;i++){
			while(t<a[i].x-1)t++,b[t]=1;
			while(h<a[i].x)c.insert(b[h]),h++;
			while(t<a[i].y)t++,b[t]=*c.begin(),c.erase(b[t]);
		}
		for(int i=1;i<=n;i++)cout<<max(b[i],1)<<' ';
		cout<<'\n';
	}
	return 0;
}

Submission Info

Submission Time
Task A - Colorful Intervals
User liruixuan
Language C++23 (GCC 15.2.0)
Score 300
Code Size 637 Byte
Status AC
Exec Time 108 ms
Memory 15348 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 3496 KiB
02_small_01.txt AC 24 ms 3572 KiB
02_small_02.txt AC 25 ms 3688 KiB
03_rand_1_01.txt AC 42 ms 3716 KiB
03_rand_1_02.txt AC 42 ms 3380 KiB
03_rand_1_03.txt AC 42 ms 3692 KiB
03_rand_1_04.txt AC 42 ms 3528 KiB
03_rand_1_05.txt AC 42 ms 3384 KiB
04_rand_2_01.txt AC 52 ms 3784 KiB
04_rand_2_02.txt AC 53 ms 3760 KiB
04_rand_2_03.txt AC 54 ms 3948 KiB
04_rand_2_04.txt AC 52 ms 3764 KiB
04_rand_2_05.txt AC 52 ms 3896 KiB
05_rand_3_01.txt AC 70 ms 13772 KiB
05_rand_3_02.txt AC 83 ms 14260 KiB
05_rand_3_03.txt AC 93 ms 14832 KiB
05_rand_3_04.txt AC 81 ms 14240 KiB
05_rand_3_05.txt AC 81 ms 14264 KiB
05_rand_3_06.txt AC 82 ms 14836 KiB
05_rand_3_07.txt AC 81 ms 14028 KiB
05_rand_3_08.txt AC 67 ms 13872 KiB
05_rand_3_09.txt AC 78 ms 14176 KiB
05_rand_3_10.txt AC 81 ms 14240 KiB
06_other_01.txt AC 16 ms 3576 KiB
06_other_02.txt AC 51 ms 13624 KiB
06_other_03.txt AC 108 ms 15216 KiB
06_other_04.txt AC 71 ms 15216 KiB
06_other_05.txt AC 70 ms 15348 KiB
06_other_06.txt AC 55 ms 15224 KiB
06_other_07.txt AC 63 ms 15336 KiB