Submission #345913

# Submission time Handle Problem Language Result Execution time Memory
345913 2021-01-08T13:21:30 Z kshitij_sodani Broken Device (JOI17_broken_device) C++14
0 / 100
35 ms 3096 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'

#include "Annalib.h"
int vis[151];
int ans[151];
/*vector<llo> yy={0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
1,1,1,1,1,1,
1,1,1,1,1,1,
1,1,1,1,1,1,
1,1,1,1,1,1};*/
void Anna( int n, long long x, int k, int pp[] ){
	for(int i=0;i<n;i++){
		vis[i]=0;
		ans[i]=0;
	}
	for(int i=0;i<k;i++){
		vis[pp[i]]=1;		
	}
	vector<int> kk;
	for(int i=0;i<n;i++){
		if(vis[i]==0){
			kk.pb(i);
		}
	}
	int cot=0;
	llo pp2=0;
	for(int i=0;i<60;i++){
		if(x&(1LL<<i)){
			pp2+=1;
		}
		else{

		}
	}
	llo st=0;
	/*if(pp2<30){
		llo y=0;

		for(int i=0;i<60;i++){
			if(x&(1LL<<i)){
				pp+=1;
			}
			else{
				y+=(1LL<<i);
			}
		}
		x=y;
		st=1;
	}*/
	while(cot<kk.size()){
		int cur=-1;
		int la=-1;
		for(int i=0;i<n;i++){
			ans[i]=0;
		}
		llo le=x;
		for(int i=0;i<n;i++){
			if(cur==60){
				break;
			}
			if(i<kk[cot]){
				continue;
			}
			if(vis[i]==0){
				if(cur==-1){
					if(i%2==st){
						ans[i]=1;
						cur++;
						la=i;
					}
					continue;
					/*if(i%2==0){
						ans[i]=1;
						cur++;
					}*/
					continue;
				}
				/*llo xx=0;
				if(cur>=40){
					xx=1;
				}*/
				if(x&(1LL<<cur)){

					if((i-la+cur)%2==1){
						le-=(1LL<<cur);
						ans[i]=1;
						cur++;
						la=i;
					}
				}
				else{
					if((i-la+cur)%2==0){
						ans[i]=1;
						cur++;
						la=i;
					}
				}
			}
		}
		if(le==0){
			break;
		}
		cot++;
		//if(cur==60){


	  }
  		for( int i = 0; i < n; i++ ){
	   		 Set( i, ans[i] );
	  	}


	  	return;

	//}
	/*cur=-1;
	for(int i=0;i<n;i++){
		ans[i]=0;
	}
	for(int i=0;i<n;i++){
		if(cur==60){
			break;
		}
		if(vis[i]==0){
			if(cur==-1){
				if(i%2==1){
					cur++;
					ans[i]=1;
				}
				continue;
			}
			if(x&(1LL<<cur)){
				if(i%2==0){
					ans[i]=1;
					cur++;
				}
			}
			else{
				if(i%2==1){
					ans[i]=1;
					cur++;
				}
			}
		}
	}

	 for( int i = 0; i < n; i++ ){
	   		 Set( i, ans[i] );
	  	}
*/
	 
}
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'


#include "Brunolib.h"
/*vector<llo> yy2={0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
	0,0,0,0,0,0,
1,1,1,1,1,1,
1,1,1,1,1,1,
1,1,1,1,1,1,
1,1,1,1,1,1};*/
long long Bruno( int n, int aa[] ){


	vector<int> ss;
	llo ans=0;
	int x=-1;
	for(int i=0;i<n;i++){
		if(aa[i]==1){
			/*if(x==-1){
				x=i;
				continue;
			}*/
			ss.pb(i);
		}
	}
	for(int i=1;i<ss.size();i++){
		/*llo xx=0;
				if(i-1>=40){
					xx=1;
				}*/
			if((ss[i]-ss[i-1]+i-1)%2==1){
			//	if(ss[0]%2==1){
					ans+=(1LL<<(i-1));
				//}
				//else{

				//}
			}
		}
	if(ss[0]%2==1){
		ans=(1LL<<60)-1-ans;
	}
	return ans;
	if(x%2==0){
		for(int i=0;i<ss.size();i++){
			if((ss[i]%2==1)){
				ans+=(1LL<<i);
			}
		}
	}
	else{
		for(int i=0;i<ss.size();i++){
			if((ss[i]%2==0)){
				ans+=(1LL<<i);
			}
		}
	}




  return ans;
}

//g++ -std=c++14 -O2 -o aa grader.cpp Anna.cpp Bruno.cpp

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:63:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |  while(cot<kk.size()){
      |        ~~~^~~~~~~~~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=1;i<ss.size();i++){
      |              ~^~~~~~~~~~
Bruno.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i=0;i<ss.size();i++){
      |               ~^~~~~~~~~~
Bruno.cpp:64:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   for(int i=0;i<ss.size();i++){
      |               ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 2816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 32 ms 2764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 32 ms 2816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 32 ms 2944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 32 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 31 ms 2824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 32 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 31 ms 2708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 31 ms 2692 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 34 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 33 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 32 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 31 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 31 ms 2700 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 30 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 31 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 31 ms 2824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 31 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 31 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 35 ms 2768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 32 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 31 ms 2876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 31 ms 2824 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 31 ms 2816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 33 ms 2804 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 32 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 33 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 31 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 31 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 32 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 31 ms 2816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 34 ms 3020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 32 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 31 ms 2620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 32 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 31 ms 3096 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 32 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 31 ms 2748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 34 ms 2636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 32 ms 2896 KB Execution killed with signal 11 (could be triggered by violating memory limits)