Submission #346107

# Submission time Handle Problem Language Result Execution time Memory
346107 2021-01-09T06:26:09 Z kshitij_sodani Broken Device (JOI17_broken_device) C++14
0 / 100
49 ms 3088 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;
	}
	//x=x^217328824795767654;
	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 mm=0;
	for(int i=0;i<60;i++){
		if((1LL<<i)&x){
			mm+=1;
		}
	}
	//while(cot<kk.size()){
		int cur=0;
		int la=-1;
		for(int i=0;i<n;i++){
			ans[i]=0;
		}
		for(int i=0;i<n;i+=3){
			if(vis[i]+vis[i+1]+vis[i+2]>1){
				continue;
			}
			if(cur>=60){
				break;
			}
			if(vis[i]+vis[i+1]+vis[i+2]==0){
				if((x&(1LL<<cur)) and (x&(1LL<<(cur+1)))){
					ans[i]=1;
					ans[i+1]=1;
					ans[i+2]=1;
				}
				if((x&(1LL<<cur)) and !(x&(1LL<<(cur+1)))){
					ans[i+1]=1;
					ans[i+2]=1;
				}
				if(!(x&(1LL<<cur)) and !(x&(1LL<<(cur+1)))){
					ans[i]=1;
				}
				if(!(x&(1LL<<cur)) and (x&(1LL<<(cur+1)))){
					ans[i]=1;
					ans[i+2]=1;
				}
				cur+=2;
			}
			else{
				if(x&(1LL<<cur)){
					if(vis[i+2]==0){
						ans[i+2]=1;
						cur+=1;
					}
					else{
						ans[i]=1;
						ans[i+1]=1;
						cur+=1;
					}
				}
				else{
					if(vis[i+1]==0){
						ans[i+1]=1;
						cur+=1;
					}
					else{
						if((x&(1LL<<cur)) and (x&(1LL<<(cur+1)))){
							ans[i]=1;
							ans[i+1]=1;
							ans[i+2]=1;
						}
						if((x&(1LL<<cur)) and !(x&(1LL<<(cur+1)))){
							ans[i+1]=1;
							ans[i+2]=1;
						}
						if(!(x&(1LL<<cur)) and !(x&(1LL<<(cur+1)))){
							ans[i]=1;
						}
						if(!(x&(1LL<<cur)) and (x&(1LL<<(cur+1)))){
							ans[i]=1;
							ans[i+2]=1;
						}
						cur+=2;
					}

				}


			}


		}
  		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[] ){
 
 
	llo ans=0;
	llo cur=0;
	for(int i=0;i<n;i+=3){
		if(aa[i]+aa[i+1]+aa[i+2]==0){
			continue;
		}
		if(cur>=60){
			break;
		}
		if(aa[i]==0 and aa[i+1]==0 and aa[i+2]==1){
			ans+=(1LL<<cur);
			cur++;
		}
		if(aa[i]==0 and aa[i+1]==1 and aa[i+2]==0){
			cur++;
		}
		if(aa[i]==0 and aa[i+1]==1 and aa[i+2]==1){
			ans+=(1LL<<cur);
			cur+=2;
		}
		if(aa[i]==1 and aa[i+1]==0 and aa[i+2]==0){
			cur+=2;
		}
		if(aa[i]==1 and aa[i+1]==0 and aa[i+2]==1){
			ans+=(1LL<<(cur+1));
			cur+=2;
		}
		if(aa[i]==1 and aa[i+1]==1 and aa[i+2]==0){
			ans+=(1LL<<cur);
			cur++;
		}
		if(aa[i]==1 and aa[i+1]==1 and aa[i+2]==1){
			ans+=(1LL<<cur)+(1LL<<(cur+1));
			cur+=2;
		}

	}
	cout<<ans<<endl;
		
		//ans=(ans^217328824795767654);
	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:39:6: warning: unused variable 'cot' [-Wunused-variable]
   39 |  int cot=0;
      |      ^~~
Anna.cpp:48:7: warning: unused variable 'la' [-Wunused-variable]
   48 |   int la=-1;
      |       ^~
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
2 Incorrect 45 ms 2744 KB Program terminated incorrectly, or you printed something to stdout
3 Incorrect 42 ms 2956 KB Program terminated incorrectly, or you printed something to stdout
4 Incorrect 42 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
5 Incorrect 42 ms 2744 KB Program terminated incorrectly, or you printed something to stdout
6 Incorrect 43 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
7 Incorrect 42 ms 3080 KB Program terminated incorrectly, or you printed something to stdout
8 Incorrect 42 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
9 Incorrect 45 ms 3088 KB Program terminated incorrectly, or you printed something to stdout
10 Incorrect 48 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
11 Incorrect 42 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
12 Incorrect 42 ms 3088 KB Program terminated incorrectly, or you printed something to stdout
13 Incorrect 44 ms 3032 KB Program terminated incorrectly, or you printed something to stdout
14 Incorrect 42 ms 2892 KB Program terminated incorrectly, or you printed something to stdout
15 Incorrect 44 ms 2740 KB Program terminated incorrectly, or you printed something to stdout
16 Incorrect 42 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
17 Incorrect 48 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
18 Incorrect 42 ms 2996 KB Program terminated incorrectly, or you printed something to stdout
19 Incorrect 43 ms 2688 KB Program terminated incorrectly, or you printed something to stdout
20 Incorrect 42 ms 2992 KB Program terminated incorrectly, or you printed something to stdout
21 Incorrect 49 ms 2836 KB Program terminated incorrectly, or you printed something to stdout
22 Incorrect 42 ms 2952 KB Program terminated incorrectly, or you printed something to stdout
23 Incorrect 45 ms 2960 KB Program terminated incorrectly, or you printed something to stdout
24 Incorrect 42 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
25 Incorrect 42 ms 2744 KB Program terminated incorrectly, or you printed something to stdout
26 Incorrect 42 ms 2744 KB Program terminated incorrectly, or you printed something to stdout
27 Incorrect 42 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
28 Incorrect 42 ms 2868 KB Program terminated incorrectly, or you printed something to stdout
29 Incorrect 42 ms 3080 KB Program terminated incorrectly, or you printed something to stdout
30 Incorrect 42 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
31 Incorrect 43 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
32 Incorrect 43 ms 2872 KB Program terminated incorrectly, or you printed something to stdout
33 Incorrect 42 ms 2952 KB Program terminated incorrectly, or you printed something to stdout
34 Incorrect 42 ms 2696 KB Program terminated incorrectly, or you printed something to stdout
35 Incorrect 42 ms 2944 KB Program terminated incorrectly, or you printed something to stdout
36 Incorrect 42 ms 2744 KB Program terminated incorrectly, or you printed something to stdout
37 Incorrect 42 ms 2952 KB Program terminated incorrectly, or you printed something to stdout
38 Incorrect 44 ms 2868 KB Program terminated incorrectly, or you printed something to stdout
39 Incorrect 42 ms 2868 KB Program terminated incorrectly, or you printed something to stdout
40 Incorrect 44 ms 2872 KB Program terminated incorrectly, or you printed something to stdout