Submission #61638534


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define int ll

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define ls o<<1
#define rs o<<1|1

bool __M1;int __st;

const int maxn=2e5+10;

struct Seg
{
	int fi,se,id;
	bool operator < (const Seg A) const
	{
		return fi!=A.fi?fi<A.fi:se<A.se;
	}
}d[maxn];

int n,m,ans[maxn];

bool check(int l,int r,int x){return l<=x and x<=r;}

void put()
{
	int num=0;
	for(int i=1;i<=m;++i)num+=bool(ans[i]);
	cout<<num<<"\n";
	for(int i=1;i<=m;++i)cout<<ans[i]<<" ";cout<<"\n";
	exit(0);
}

bool __M2;

signed main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m;

	for(int i=1;i<=m;++i)
		cin>>d[i].fi>>d[i].se,d[i].id=i;

	for(int i=1;i<=m;++i)
		if(d[i].fi==1 and d[i].se==n)
		{
			cout<<1<<"\n";
			for(int j=1;j<i;++j)cout<<0<<" ";
			cout<<1<<" ";
			for(int j=i+1;j<=m;++j)cout<<0<<" ";cout<<"\n";
			return 0;
		}	
	
	sort(d+1,d+1+m);
	
	for(int i=2,id=1;i<=m;++i)
	{
		if(d[i].se<=d[id].se)
		{
			ans[d[id].id]=1,ans[d[i].id]=2;
			put();
		}
		if(d[id].se<=d[i].se)id=i;
	}
	
	int L=1,R=1;
	
	for(int i=1;i<=m;++i)
	{
		if(d[i].fi>d[L].fi)L=i;
		if(d[i].se<d[R].se)R=i;
	}
	
	if(d[L].fi>d[R].se)
	{
		ans[d[L].id]=ans[d[R].id]=2;
		put();
	}
	
	for(int i=2,id=1;i<=m;++i)
	{
		if(d[i].fi==1 and d[i].se>d[id].se)id=i;
		if(d[i].se==n and d[i].fi-1<=d[id].se)
		{
			ans[d[id].id]=ans[d[i].id]=1;
			put();
		}
	}
	
	for(int i=1;i<=m;++i)
		if(i!=L and i!=R)
		{
			if(d[i].fi-1<=d[L].fi and d[i].se+1>=d[R].se)
			{
				ans[d[i].id]=1;
				ans[d[L].id]=ans[d[R].id]=2;
				put();
			}
		}
	
	cout<<"-1\n";

	cerr<<"\n"<<(&__M1-&__M2)/1024/1024<<"MB\n"<<(clock()-__st)<<"ms\n";

	cout.flush(),fclose(stdin),fclose(stdout);
	return 0;
}

Submission Info

Submission Time
Task A - Inside or Outside
User qinyun
Language C++ 20 (gcc 12.2)
Score 700
Code Size 1901 Byte
Status AC
Exec Time 45 ms
Memory 8312 KiB

Compile Error

Main.cpp: In function ‘void put()’:
Main.cpp:34:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   34 |         for(int i=1;i<=m;++i)cout<<ans[i]<<" ";cout<<"\n";
      |         ^~~
Main.cpp:34:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   34 |         for(int i=1;i<=m;++i)cout<<ans[i]<<" ";cout<<"\n";
      |                                                ^~~~
Main.cpp: In function ‘int main()’:
Main.cpp:57:25: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   57 |                         for(int j=i+1;j<=m;++j)cout<<0<<" ";cout<<"\n";
      |                         ^~~
Main.cpp:57:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   57 |                         for(int j=i+1;j<=m;++j)cout<<0<<" ";cout<<"\n";
      |                                                             ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 67
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 02_small_11.txt, 02_small_12.txt, 02_small_13.txt, 02_small_14.txt, 02_small_15.txt, 02_small_16.txt, 02_small_17.txt, 03_max_rand_1_01.txt, 03_max_rand_1_02.txt, 03_max_rand_1_03.txt, 03_max_rand_1_04.txt, 03_max_rand_1_05.txt, 04_max_rand_2_01.txt, 04_max_rand_2_02.txt, 04_max_rand_2_03.txt, 04_max_rand_2_04.txt, 04_max_rand_2_05.txt, 05_one_01.txt, 05_one_02.txt, 06_three_01.txt, 06_three_02.txt, 06_three_03.txt, 06_three_04.txt, 06_three_05.txt, 06_three_06.txt, 06_three_07.txt, 06_three_08.txt, 06_three_09.txt, 06_three_10.txt, 07_two_01.txt, 07_two_02.txt, 07_two_03.txt, 07_two_04.txt, 07_two_05.txt, 07_two_06.txt, 07_two_07.txt, 07_two_08.txt, 07_two_09.txt, 07_two_10.txt, 07_two_11.txt, 07_two_12.txt, 07_two_13.txt, 07_two_14.txt, 07_two_15.txt, 07_two_16.txt, 07_two_17.txt, 07_two_18.txt, 07_two_19.txt, 08_special_01.txt, 08_special_02.txt, 08_special_03.txt, 08_special_04.txt, 08_special_05.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 1 ms 3476 KiB
01_sample_02.txt AC 1 ms 3528 KiB
01_sample_03.txt AC 1 ms 3400 KiB
01_sample_04.txt AC 1 ms 3548 KiB
02_small_01.txt AC 1 ms 3668 KiB
02_small_02.txt AC 1 ms 3532 KiB
02_small_03.txt AC 1 ms 3476 KiB
02_small_04.txt AC 1 ms 3480 KiB
02_small_05.txt AC 1 ms 3468 KiB
02_small_06.txt AC 1 ms 3420 KiB
02_small_07.txt AC 1 ms 3468 KiB
02_small_08.txt AC 1 ms 3532 KiB
02_small_09.txt AC 1 ms 3404 KiB
02_small_10.txt AC 1 ms 3532 KiB
02_small_11.txt AC 1 ms 3404 KiB
02_small_12.txt AC 1 ms 3428 KiB
02_small_13.txt AC 1 ms 3436 KiB
02_small_14.txt AC 1 ms 3348 KiB
02_small_15.txt AC 1 ms 3452 KiB
02_small_16.txt AC 1 ms 3484 KiB
02_small_17.txt AC 3 ms 3724 KiB
03_max_rand_1_01.txt AC 43 ms 8180 KiB
03_max_rand_1_02.txt AC 43 ms 8108 KiB
03_max_rand_1_03.txt AC 43 ms 8064 KiB
03_max_rand_1_04.txt AC 43 ms 8180 KiB
03_max_rand_1_05.txt AC 43 ms 8116 KiB
04_max_rand_2_01.txt AC 43 ms 8164 KiB
04_max_rand_2_02.txt AC 43 ms 8176 KiB
04_max_rand_2_03.txt AC 43 ms 8184 KiB
04_max_rand_2_04.txt AC 43 ms 8152 KiB
04_max_rand_2_05.txt AC 43 ms 8096 KiB
05_one_01.txt AC 25 ms 7632 KiB
05_one_02.txt AC 15 ms 5972 KiB
06_three_01.txt AC 35 ms 7036 KiB
06_three_02.txt AC 42 ms 7976 KiB
06_three_03.txt AC 43 ms 7984 KiB
06_three_04.txt AC 12 ms 4712 KiB
06_three_05.txt AC 39 ms 7752 KiB
06_three_06.txt AC 22 ms 5920 KiB
06_three_07.txt AC 28 ms 6472 KiB
06_three_08.txt AC 5 ms 3912 KiB
06_three_09.txt AC 42 ms 7996 KiB
06_three_10.txt AC 33 ms 6932 KiB
07_two_01.txt AC 45 ms 8120 KiB
07_two_02.txt AC 44 ms 8152 KiB
07_two_03.txt AC 45 ms 8176 KiB
07_two_04.txt AC 44 ms 8104 KiB
07_two_05.txt AC 44 ms 8100 KiB
07_two_06.txt AC 45 ms 8112 KiB
07_two_07.txt AC 44 ms 8232 KiB
07_two_08.txt AC 45 ms 8176 KiB
07_two_09.txt AC 43 ms 8124 KiB
07_two_10.txt AC 44 ms 8100 KiB
07_two_11.txt AC 44 ms 8312 KiB
07_two_12.txt AC 44 ms 8156 KiB
07_two_13.txt AC 44 ms 8108 KiB
07_two_14.txt AC 44 ms 8104 KiB
07_two_15.txt AC 45 ms 8136 KiB
07_two_16.txt AC 44 ms 8060 KiB
07_two_17.txt AC 44 ms 8176 KiB
07_two_18.txt AC 44 ms 8180 KiB
07_two_19.txt AC 44 ms 8232 KiB
08_special_01.txt AC 31 ms 8152 KiB
08_special_02.txt AC 31 ms 8096 KiB
08_special_03.txt AC 1 ms 3544 KiB
08_special_04.txt AC 1 ms 3608 KiB
08_special_05.txt AC 1 ms 3404 KiB