Submission #146307

# Submission time Handle Problem Language Result Execution time Memory
146307 2019-08-23T12:05:17 Z MvC Alternating Current (BOI18_alternating) C++11
13 / 100
3000 ms 3360 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,t,vz[nmax],rs[nmax],nr,l;
pair<int,int>a[nmax];
vector<int>rad;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=m;i++)cin>>a[i].fr>>a[i].sc;
	for(i=1;i<=m;i++)rad.pb(i);
	while((double)clock()/CLOCKS_PER_SEC<2.950)
	{
		shuffle(rad.begin(),rad.end(),rng);
		nr=n;
		for(i=1;i<=n;i++)vz[i]=0;
		for(i=0;i<m;i++)
		{
			j=rad[i];
			if(a[j].fr<=a[j].sc)
			{
				for(t=a[j].fr;t<=a[j].sc;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
			}
			else
			{
				for(t=a[j].fr;t<=n;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
				for(t=1;t<=a[j].sc;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
			}
			if(!nr)break;
		}
		for(j=1;j<=n;j++)vz[j]=0;
		nr=n;
		l=i;
		for(i++;i<m;i++)
		{
			j=rad[i];
			if(a[j].fr<=a[j].sc)
			{
				for(t=a[j].fr;t<=a[j].sc;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
			}
			else
			{
				for(t=a[j].fr;t<=n;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
				for(t=1;t<=a[j].sc;t++)
				{
					if(!vz[t])nr--;
					vz[t]=1;
				}
			}
			if(!nr)break;
		}
		if(i<m)
		{
			for(i=l+1;i<m;i++)rs[rad[i]]=1;
			for(i=1;i<=m;i++)cout<<rs[i];
			cout<<endl;
			exit(0);
		}
	}
	cout<<"impossible"<<endl;
	return 0;
}

Compilation message

alternating.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
alternating.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2950 ms 392 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2950 ms 380 KB Output is correct
11 Correct 2950 ms 396 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2950 ms 476 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2950 ms 404 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2950 ms 400 KB Output is correct
30 Correct 2950 ms 396 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2950 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2950 ms 388 KB Output is correct
35 Correct 2950 ms 504 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2950 ms 392 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2950 ms 392 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2950 ms 380 KB Output is correct
11 Correct 2950 ms 396 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2950 ms 476 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2950 ms 404 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2950 ms 400 KB Output is correct
30 Correct 2950 ms 396 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2950 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2950 ms 388 KB Output is correct
35 Correct 2950 ms 504 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2950 ms 392 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Incorrect 2950 ms 476 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2950 ms 392 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2950 ms 380 KB Output is correct
11 Correct 2950 ms 396 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2950 ms 476 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2950 ms 404 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2950 ms 400 KB Output is correct
30 Correct 2950 ms 396 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2950 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2950 ms 388 KB Output is correct
35 Correct 2950 ms 504 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2950 ms 392 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Incorrect 2950 ms 476 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3360 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Execution timed out 3034 ms 2036 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2950 ms 392 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2950 ms 380 KB Output is correct
11 Correct 2950 ms 396 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2950 ms 476 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 296 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2950 ms 404 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2950 ms 400 KB Output is correct
30 Correct 2950 ms 396 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2950 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2950 ms 388 KB Output is correct
35 Correct 2950 ms 504 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2950 ms 392 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Incorrect 2950 ms 476 KB 'impossible' claimed, but there is a solution
44 Halted 0 ms 0 KB -