Submission #254077

# Submission time Handle Problem Language Result Execution time Memory
254077 2020-07-29T10:38:37 Z Markoes Cards (LMIO19_korteles) C++14
100 / 100
153 ms 19576 KB
#include<bits/stdc++.h>

using namespace std;
int n,c[4],atas,bawah,kanan,kiri;
char cc;
long long satu,kdua,dua,kempat,empat,up[680],dn[680],le[680],ri[680],cas[6][680][680];
bool cek[30][30];
int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);cout.tie(0);
	cin>>n;
	memset(up,0,sizeof up);
	memset(dn,0,sizeof dn);
	memset(le,0,sizeof le);
	memset(ri,0,sizeof ri);
	satu = 0;
	dua = 0;
	empat = 0;
	memset(cek,0,sizeof cek);
	for(int i=1;i<=n;i++){
		for(int j=0;j<4;j++){
			cin>>cc;
			c[j] = (int)(cc-'A');
		}
		if(c[0] == c[3] && c[1] == c[2] && c[0] == c[1]){
			kempat++;
		}
		else if(c[0] == c[1] && c[2] == c[3]) kdua++;
		else if(c[0] == c[2] && c[1] == c[3]) kdua++;
		else if(c[0] == c[3] && c[1] == c[2]){
			cek[c[0]][c[1]] = 1;
			if(cek[c[1]][c[0]]){
				empat++;
			}
		}
		atas = c[0]*26+c[1];
		bawah = c[2]*26+c[3];
		kanan = c[1]*26+c[3];
		kiri = c[0]*26+c[2];
		up[atas]++;
		dn[bawah]++;
		le[kiri]++;
		ri[kanan]++;
		
		cas[0][atas][bawah]++;
		cas[1][kiri][kanan]++;
		cas[2][kiri][atas]++;
		cas[3][atas][kanan]++;
		cas[4][kiri][bawah]++;
		cas[5][bawah][kanan]++;
	}
//	cout<<"kdua kempat empat "<<kdua<<' '<<kempat<<' '<<empat<<endl;
	for(int i=0;i<676;i++){
		for(int j=0;j<676;j++){
			dua += cas[0][i][j] * cas[0][j][i];
			dua += cas[1][i][j] * cas[1][j][i];
			dua += cas[2][i][j] * cas[5][j][i];
			dua += cas[3][i][j] * cas[4][j][i];
			dua += cas[4][i][j] * cas[3][j][i];
			dua += cas[5][i][j] * cas[2][j][i];
		}
	}
//	cout<<"dua bruto "<<dua<<endl;
	dua -= kempat*6;
	dua -= kdua;
	dua /= 2;
	dua -= empat*6;
//	cout<<"dua neto "<<dua<<endl;
	for(int i=0;i<676;i++){
		satu += up[i]*dn[i];
		satu += le[i]*ri[i];
		satu += up[i]*dn[i];
		satu += le[i]*ri[i];
	}
	satu -= kempat*4;
	satu -= kdua*2;
	satu /= 2;
	satu -= dua*2;
	satu -= empat*4;
	
//	cout<<satu<<' '<<dua<<' '<<empat<<endl;
	cout<<satu+dua+empat<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 22 ms 512 KB Output is correct
3 Correct 22 ms 1280 KB Output is correct
4 Correct 23 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 512 KB Output is correct
2 Correct 29 ms 10404 KB Output is correct
3 Correct 24 ms 2560 KB Output is correct
4 Correct 35 ms 18432 KB Output is correct
5 Correct 29 ms 9984 KB Output is correct
6 Correct 32 ms 13824 KB Output is correct
7 Correct 22 ms 384 KB Output is correct
8 Correct 22 ms 384 KB Output is correct
9 Correct 22 ms 512 KB Output is correct
10 Correct 22 ms 1280 KB Output is correct
11 Correct 23 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 19456 KB Output is correct
2 Correct 153 ms 19524 KB Output is correct
3 Correct 136 ms 19456 KB Output is correct
4 Correct 139 ms 19456 KB Output is correct
5 Correct 135 ms 19456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 50 ms 19072 KB Output is correct
3 Correct 106 ms 19116 KB Output is correct
4 Correct 75 ms 19072 KB Output is correct
5 Correct 77 ms 19072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 512 KB Output is correct
2 Correct 29 ms 10404 KB Output is correct
3 Correct 24 ms 2560 KB Output is correct
4 Correct 35 ms 18432 KB Output is correct
5 Correct 29 ms 9984 KB Output is correct
6 Correct 32 ms 13824 KB Output is correct
7 Correct 22 ms 384 KB Output is correct
8 Correct 22 ms 384 KB Output is correct
9 Correct 22 ms 512 KB Output is correct
10 Correct 22 ms 1280 KB Output is correct
11 Correct 23 ms 1664 KB Output is correct
12 Correct 134 ms 19456 KB Output is correct
13 Correct 153 ms 19524 KB Output is correct
14 Correct 136 ms 19456 KB Output is correct
15 Correct 139 ms 19456 KB Output is correct
16 Correct 135 ms 19456 KB Output is correct
17 Correct 50 ms 19072 KB Output is correct
18 Correct 106 ms 19116 KB Output is correct
19 Correct 75 ms 19072 KB Output is correct
20 Correct 77 ms 19072 KB Output is correct
21 Correct 60 ms 19520 KB Output is correct
22 Correct 113 ms 19576 KB Output is correct
23 Correct 88 ms 19576 KB Output is correct
24 Correct 85 ms 19456 KB Output is correct