Submission #29936

# Submission time Handle Problem Language Result Execution time Memory
29936 2017-07-21T11:02:26 Z aybala Cave (IOI13_cave) C++14
Compilation error
0 ms 0 KB
#include "cave.h"

#include<bits/stdc++.h>
#define fori(a,b,c) for(int a=b; a<c; a++)
#define ford(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;

int n;

int sw[5000];
#include "cave.h"

#include<bits/stdc++.h>
#define fori(a,b,c) for(int a=b; a<c; a++)
#define ford(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;

int n;

int sw[5000];

int used[5000];

pii b[8900];
//pii a[8900];

int s[5000],d[5000];

void exploreCave(int N) {
	n=N;
	
	int lg=0;
	
	while((1<<lg) < n){
		lg++;
	}
	
	cout << lg;
	
	int nn=(1<<lg);
	
	fori(i,0,n){
		int las=0;
		fori(j,0,lg+1){
			fori(k,las,las+(nn/(1<<j))){
				if(k>=n)
					break;
				if(!used[k]){
					sw[k]=(b[i].se+1)%2;
				}
				else{
					sw[k]=s[k];
				}
			}
			if(las>=n){
				continue;
			}
			int trc=tryCombination(sw);
			
			
			/*if(n==1){
				if(trc!=i){
					b[i].se=1;
				}
				d[i]=i;
				s[i]=b[i].se;
			}
			
			if(j==lg){
				if(trc!=i){
					used[las+1]=1;
					b[i].fi=las+1;
					d[las+1]=i;
					s[las+1]=b[i].se;
				}
				else{
					used[las]=1;
					b[i].fi=las;
					d[las]=i;
					s[las]=b[i].se;
				}
				break;
			}
			
			if(trc!=i && j==0){
				b[i].se = 1;
				continue;
			}
			
			if(trc==i && j==0){
				fori(k,las,las+(nn/(1<<j))){
					if(k>=n)
						break;
					if(!used[k]){
						sw[k]=0;
					}
					else{
						sw[k]=s[k];
					}
				}
				continue;
			}
			
			if(trc!=i && j!=0){
				if(las+(nn/(1<<j)) <n)
					las=las+(nn/(1<<j));
				continue;
			}
			
			if(trc==i && j!=0){
				fori(k,las,las+(nn/(1<<j))){
					if(k>=n)
						break;
					if(!used[k]){
						sw[k]=(b[i].se)%2;
					}
					else{
						sw[k]=s[k];
					}
				}
				continue;	
			}		
			
			
			*/
		}
	}	
	
	/*fori(i,0,n){
		s[i]=a[i].se;
		d[i]=a[i].fi;
	}*/
	
	/*fori(i,0,80000){
		tryCombination(sw);
	}*/
	answer(s,d);
	return ;
}

int used[5000];

pii b[8900];
//pii a[8900];

int s[5000],d[5000];

void exploreCave(int N) {
	n=N;
	
	int lg=0;
	
	while((1<<lg) < n){
		lg++;
	}
	
	cout << lg;
	
	int nn=(1<<lg);
	
	fori(i,0,n){
		int las=0;
		int x=0;
		fori(j,0,lg+1){
			fori(k,las,las+(nn/(1<<j))+x){
				if(k>=n)
					break;
				if(!used[k]){
					sw[k]=(b[i].se+1)%2;
				}
				else{
					sw[k]=s[k];
				}
			}
			if(las>=n){
				continue;
			}
			int trc=tryCombination(sw);
			
			
			if(n==1){
				if(trc!=i){
					b[i].se=1;
				}
				d[i]=i;
				s[i]=b[i].se;
			}
			
			if(j==lg){
				if(trc!=i){
					used[las+1]=1;
					b[i].fi=las+1;
					d[las+1]=i;
					s[las+1]=b[i].se;
				}
				else{
					used[las]=1;
					b[i].fi=las;
					d[las]=i;
					s[las]=b[i].se;
				}
				break;
			}
			
			if(trc!=i && j==0){
				b[i].se = 1;
				continue;
			}
			
			if(trc==i && j==0){
				fori(k,las,las+(nn/(1<<j))+x){
					if(k>=n)
						break;
					if(!used[k]){
						sw[k]=0;
					}
					else{
						sw[k]=s[k];
					}
				}
				continue;
			}
			
			if(trc!=i && j!=0){
				if(las+(nn/(1<<(j)))+x <n)
					las=las+(nn/(1<<j))+x;
				continue;
			}
			
			if(trc==i && j!=0){
				fori(k,las,las+(nn/(1<<j))+x){
					if(k>=n)
						break;
					if(!used[k]){
						sw[k]=(b[i].se)%2;
					}
					else{
						sw[k]=s[k];
					}
				}
				continue;	
			}		
			
			
			
		}
	}	
	
	/*fori(i,0,n){
		s[i]=a[i].se;
		d[i]=a[i].fi;
	}*/
	
	/*fori(i,0,80000){
		tryCombination(sw);
	}*/
	answer(s,d);
	return ;
}

Compilation message

cave.cpp:30:5: error: redefinition of 'int n'
 int n;
     ^
cave.cpp:14:5: note: 'int n' previously declared here
 int n;
     ^
cave.cpp:32:12: error: redefinition of 'int sw [5000]'
 int sw[5000];
            ^
cave.cpp:16:5: note: 'int sw [5000]' previously declared here
 int sw[5000];
     ^~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:70:8: warning: unused variable 'trc' [-Wunused-variable]
    int trc=tryCombination(sw);
        ^~~
cave.cpp: At global scope:
cave.cpp:153:14: error: redefinition of 'int used [5000]'
 int used[5000];
              ^
cave.cpp:34:5: note: 'int used [5000]' previously declared here
 int used[5000];
     ^~~~
cave.cpp:155:11: error: redefinition of 'std::pair<int, int> b [8900]'
 pii b[8900];
           ^
cave.cpp:36:5: note: 'std::pair<int, int> b [8900]' previously defined here
 pii b[8900];
     ^
cave.cpp:158:11: error: redefinition of 'int s [5000]'
 int s[5000],d[5000];
           ^
cave.cpp:39:5: note: 'int s [5000]' previously declared here
 int s[5000],d[5000];
     ^
cave.cpp:158:19: error: redefinition of 'int d [5000]'
 int s[5000],d[5000];
                   ^
cave.cpp:39:13: note: 'int d [5000]' previously declared here
 int s[5000],d[5000];
             ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:160:6: error: redefinition of 'void exploreCave(int)'
 void exploreCave(int N) {
      ^~~~~~~~~~~
cave.cpp:41:6: note: 'void exploreCave(int)' previously defined here
 void exploreCave(int N) {
      ^~~~~~~~~~~