CSES - Datatähti 2021 alku - Results
Submission details
Task:Arpakuutiot
Sender:Guuber
Submission time:2020-10-01 21:30:56 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'bool samat(std::vector<int>, std::vector<int>)':
input/code.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < a.size(); i++){
                  ~~^~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:154:13: warning: unused variable 'co' [-Wunused-variable]
         int co = 0;
             ^~
input/code.cpp:155:13: warning: variable 'edellinen' set but not used [-Wunused-but-set-variable]
         int edellinen = 0;
             ^~~~~~~~~
input/code.cpp:76:11: warning: unused variable 'co' [-Wunused-variable]
       int co = 0;
           ^~
input/code.cpp:288:27: error: 'jarjestys' was not declared in this scope
      vastaukset.push_back(jarjestys);
                           ^~~~~~~~~
input/code.cpp:299:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < vastaukset.size(); i++){
                  ~~^~~~~~~~~~...

Code

#include<bits/stdc++.h>
using namespace std;
 
char s[10][10];
int z[10][10];
int loppu[10][10];
 
int paalla;
int edessa;
int vasemmalla;
int oikealla;
int takana;
int alhaalla;
int coo = 0;
 
vector<vector<int>> vastaukset = {};
bool samat(vector<int> a, vector<int> b){
		for(int i = 0; i < a.size(); i++){
				if(a[i] != b[i]) return false;
		}
		return true;
}
 
// int paalla = s[2][1]-'0';
// int edessa = s[1][1]-'0';
// int vasemmalla = s[0][0]-'0';
// int oikealla = s[0][2]-'0';
// int takana = s[3][1]-'0';
// int alhaalla = s[0][1]-'0';
 
vector<int> rotatex(vector<int> a1){
		return {a1[0], a1[3], a1[1], a1[4], a1[2], a1[5]};
}
 
vector<int> rotatey(vector<int> a1){
		return {a1[1], a1[5], a1[2], a1[3], a1[0], a1[4]};
}
 
bool tarkista(vector<int> a, vector<int> b){
		for(int k = 0; k < 2; k++){
				for(int j = 0; j < 4; j++){
						for(int i = 0; i < 4; i++){
								if(samat(a, b)) return 1;
								a = rotatex(a);
						}
						a = rotatey(a);
				}
				a = rotatex(a);
		}
		return 0;
}
 
vector<pair<int,int>> historia;
vector<pair<int,int>> historia2;
int main(){
 
		int n;
		cin >> n;
		for(int ss = 0; ss < n; ss++){
				for(int i = 1; i < 6; i++){
						for(int j = 1; j < 6; j++){
								cin >> s[i][j];
						}
				}
 
				for(int i = 0; i <= 6; i++){
						s[0][i] = '.';
						s[6][i] = '.';
						s[i][0] = '.';
						s[i][6] = '.';
				}
				bool boi = false;
				for(int yy = 1; yy <= 6; yy++){
					if(boi) break;
					for(int xx = 1; xx <= 6; xx++){ 
						int co = 0;
						bool boss = 1;
						bool bo = 0;
						int x = 0;
						int y = 0;
						
						for(int i = 1; i < 6; i++){
								if(bo) break;
								for(int j = 1; j < 6; j++){
		 
										int e = 0;
										int a = 0;
										int b = 0;
										int c = 0;
										int d = 0;
		 
										if(s[i-1][j] != '.'){
												a = (s[i-1][j-1]!= '.') + (s[i-1][j+1] != '.') + (s[i-2][j] != '.');
										}
		 
										if(s[i+1][j] != '.'){
												b = (s[i+1][j-1] != '.') + (s[i+1][j-1] != '.') + (s[i+2][j]!= '.');
										}
		 
										if(s[i][j-1]!= '.'){
												c = (s[i][j-2]!= '.') + (s[i+1][j-1] != '.') + (s[i-1][j+1] != '.');
										}
		 
										if(s[i][j+1] != '.'){
												d = (s[i][j+2] != '.') + (s[i+1][j+1] != '.') + (s[i+1][j-1]!= '.');
										}
		 
		 
										if(s[i][j] != '.' ){
												e = (s[i-1][j] != '.') + (s[i+1][j] != '.') + (s[i][j-1] != '.') + (s[i][j+1] != '.');
										}
		 
										if(s[i][j]!= '.' && e == 1 && a < 2 && b < 2 && c < 2 && d < 2){
												bo = true;
												x = j;
												y = i;
												if(boss){
														boss = 0;
												}
										}
								}
						}
						int alkux = x;
						int alkuy = y;
						vector<int> jarjestys = {1,2,3,4,5,6};
						do{
								x = alkux;
								y = alkuy;
		 
								paalla = jarjestys[0];
								edessa = jarjestys[1];
								vasemmalla = jarjestys[2];
								oikealla = jarjestys[3];
								takana = jarjestys[4];
								alhaalla = jarjestys[5];
		 
								int paalla2;
								int edessa2;
								int vasemmalla2;
								int oikealla2;
								int takana2;
								int alhaalla2;
								for(int i = 0; i < 10; i++){
										for(int j  = 0; j < 10; j++){
												z[i][j] = 0;
												loppu[i][j] = 0;
										}
								}
								bo = false;
								int cs = 0;
								int x2 = x;
								int y2 = y;
								z[y][x] = 1;
								int co = 0;
								int edellinen = 0;
					historia = {};
					historia2 = {};
					while(cs < 5){
						int counter = 0;
										z[y][x] = 1;
										loppu[y][x] = alhaalla;
											
										if(s[y-1][x] != '.' && !z[y-1][x]){
						  historia2.push_back({y-1,x});
											if((s[y-2][x] != '.' && !z[y-2][x]) || (s[y-1][x-1] != '.'&& !z[y-1][x-1]) || (s[y-1][x+1] != '.'&& !z[y-1][x+1])){
		 
														bo = true;
														x2 = x;
														y2 = y-1;
		 
														paalla2 = edessa;
														edessa2 = 0;
														takana2 = paalla;
														vasemmalla2 = vasemmalla;
														oikealla2 = oikealla;
														alhaalla2 = takana;
								counter++;
												}else{
		 
														loppu[y-1][x] = takana;
														takana2 = 0;
														z[y-1][x] = 1;
												}
												cs++;
										}
										if(s[y+1][x] != '.' && !z[y+1][x]){
						  historia2.push_back({y+1, x});
		 
												if((s[y+2][x]!= '.' && !z[y+2][x]) || (s[y+1][x+1] != '.'&& !z[y+1][x+1]) || (s[y+1][x-1] != '.'&& !z[y+1][x-1])){
		 
														x2 = x;
														y2 = y+1;
														paalla2 = takana;
														edessa2 = paalla;
														takana2 = 0;
														vasemmalla2 = vasemmalla;
														oikealla2 = oikealla;
														alhaalla2 = edessa;
								counter++;
		 
												}else{
		 
														loppu[y+1][x] = edessa;
														edessa2 = 0;
														z[y+1][x] = 1;
												}
												cs++;
										}
										if(s[y][x+1] != '.' && !z[y][x+1]){
						  historia2.push_back({y,x+1});
		 
												if( (s[y][x+2] != '.' && !z[y][x+2]) || (s[y-1][x+1] != '.' && !z[y-1][x+1]) || (s[y+1][x+1] != '.' && !z[y+1][x+1])){
		 
		//										if( (s[y][x+2] != '.' && !z[y][x+2]) || (s[y-1][x+1] != '.'&& !z[y-1][x+1]) ||(s[y+1][x+1] != '.'&& !z[y+1][x+1]) ){
		 
														x2 = x+1;
														y2 = y;
														paalla2 = vasemmalla;
														edessa2 = edessa;
														takana2 = takana;
														vasemmalla2 = 0;
														oikealla2 = paalla;
														alhaalla2 = oikealla;
								counter++;
												}else{
		 
														loppu[y][x+1] = oikealla;
														oikealla2 = 0;
														z[y][x+1] = 1;
												}
												cs++;
										}
										if(s[y][x-1] != '.' && !z[y][x-1]){
						  historia2.push_back({y, x-1});
		 
												
												if( (s[y-1][x-1] != '.'&& !z[y-1][x-1]) || (s[y+1][x-1] != '.' && !z[y+1][x-1]) || (s[y][x-2] != '.' && !z[y][x-2]) ){ 
											//	if( (s[y][x-2] != '.' && !z[y][x-2]) || (s[y-1][x-1] != '.'&& !z[y-1][x-1]) || (s[y+1][x-1] != '.'&& !z[y+1][x-1]) ){
														x2 = x-1;
														y2 = y;
														paalla2 = oikealla;
														edessa2 = edessa;
														takana2 = takana;
														vasemmalla2 = paalla;
														oikealla2 = 0;
														alhaalla2 = vasemmalla;
								counter++;
		 
												}else{
		 
														loppu[y][x-1] = vasemmalla;
														vasemmalla2 = 0;
														z[y][x-1] = 1;
		 
												}
												cs++;
										}
										x = x2;
										y = y2;
										alhaalla = alhaalla2;
										oikealla = oikealla2;
										paalla = paalla2;
										takana = takana2;
										edessa = edessa2;
										vasemmalla = vasemmalla2;
										takana = takana2;
								
										
										
										edellinen = cs;
								} // cs loppuu
								bool bo2 = true;
								for(int i = 1; i < 6; i++){
										for(int j = 1; j < 6; j++){
												if((int)(s[i][j]-'0') != loppu[i][j] && s[i][j] != '.'){
														bo2 = false;
														boi = true;
												}
										}
								}
								if(bo2) break;
		 
						}
						while(next_permutation(jarjestys.begin(), jarjestys.end()));
					}
				}
				if(boi){
					vastaukset.push_back(jarjestys);
					break;
				}
 
				//cout << "Paalla: " << jarjestys[0] << "\n";
				//cout << "Edessa: " << jarjestys[1] << "\n";
				//cout << "Vasemmalla: " << jarjestys[2] << "\n";
				//cout << "Oikealla: " << jarjestys[3] << "\n";
				//cout << "Takana: " << jarjestys[4] << "\n";
				//cout << "Alhaalla: " << jarjestys[5] << "\n";
		}
		for(int i = 0; i < vastaukset.size(); i++){
				bool sdf = false;
				for(int j = 0; j < vastaukset.size(); j++){
						if(tarkista(vastaukset[i], vastaukset[j]) && i != j){
								sdf = true;
								cout << j+1 << " ";
						}
				}
				if(!sdf) cout << "-";
				cout << "\n";
		}
}