Submission #589889

# Submission time Handle Problem Language Result Execution time Memory
589889 2022-07-05T11:20:57 Z ignus Cards (LMIO19_korteles) C++14
100 / 100
184 ms 4880 KB
 #include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[4][676];
	int b[4][676];
	int c[456976];
	long long fin = 0;
	for(int i = 0; i < 676; i++){
		for(int j = 0; j < 4; j++)a[j][i]=0;
		for(int j = 0; j < 4; j++)b[j][i]=0;
	}
	for(int i = 0; i < 456976; i++){
		c[i]=0;
	}
	for(int i = 0; i < n; i++){
		char t1, t2, t3, t4;
		cin >> t1 >> t2 >> t3 >> t4;
		t1-='A';
		t2-='A';
		t3-='A';
		t4-='A';
		long long r1=0, r4=0, r2c=0, r2o=0;
		
		if(t1==t4&&t2==t3){
			r4+=c[26*(26*(26*(t3)+t4)+t1)+t2];
		}
		if(t1==t4){
			r2c+=b[1][26*(t2)+t1]-r4;
			r2c+=b[0][26*(t3)+t1]-r4;
		//	cout << b[1][26*(t2)+t1] << ' ' << b[0][26*(t3)+t1] << ' ';
		}
		if(t2==t3){
			r2c+=b[3][26*(t4)+t2]-r4;
			r2c+=b[2][26*(t1)+t2]-r4;
		//	cout << b[3][26*(t4)+t2] << ' ' << b[2][26*(t1)+t2];
		}
		r2o+=c[26*(26*(26*(t2)+t1)+t4)+t3]-r4;
		r2o+=c[26*(26*(26*(t3)+t4)+t1)+t2]-r4;
		r1=a[0][26*(t3)+t4]+a[1][26*(t1)+t2]+a[2][26*(t2)+t4]+a[3][26*(t1)+t3]-r4*4-r2c*2-r2o*2;
		fin+=r1+r2o+r2c+r4;
		//cout << '\n';
		//cout << a[0][26*(t3)+t4] << ' '<< a[1][26*(t1)+t2] << ' ' << a[2][26*(t2)+t4] << ' ' << a[3][26*(t1)+t3] <<'\n';
		//cout << i << ' ' << fin << ' ' << r1 << ' ' << r2o << ' ' << r2c << ' ' << r4 << '\n';
		if(t1==t4){
			b[0][26*(t1)+t2]++;
			b[1][26*(t1)+t3]++;
		}
		
		if(t2==t3){
			b[3][26*(t2)+t1]++;
			b[2][26*(t2)+t4]++;
		}
		
		c[26*(26*(26*(t1)+t2)+t3)+t4]++;
		
		a[0][26*(t1)+t2]++;
		a[1][26*(t3)+t4]++;
		a[2][26*(t1)+t3]++;
		a[3][26*(t2)+t4]++;
	}
	cout << fin;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2048 KB Output is correct
2 Correct 3 ms 2004 KB Output is correct
3 Correct 2 ms 2004 KB Output is correct
4 Correct 2 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2048 KB Output is correct
2 Correct 3 ms 2004 KB Output is correct
3 Correct 2 ms 2004 KB Output is correct
4 Correct 2 ms 2004 KB Output is correct
5 Correct 1 ms 2004 KB Output is correct
6 Correct 1 ms 2004 KB Output is correct
7 Correct 3 ms 2156 KB Output is correct
8 Correct 3 ms 2004 KB Output is correct
9 Correct 3 ms 2004 KB Output is correct
10 Correct 3 ms 2004 KB Output is correct
11 Correct 2 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 4752 KB Output is correct
2 Correct 137 ms 4760 KB Output is correct
3 Correct 122 ms 4636 KB Output is correct
4 Correct 125 ms 4880 KB Output is correct
5 Correct 137 ms 4632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2004 KB Output is correct
2 Correct 16 ms 2392 KB Output is correct
3 Correct 78 ms 3744 KB Output is correct
4 Correct 52 ms 3100 KB Output is correct
5 Correct 51 ms 3088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2004 KB Output is correct
2 Correct 1 ms 2004 KB Output is correct
3 Correct 3 ms 2156 KB Output is correct
4 Correct 3 ms 2004 KB Output is correct
5 Correct 3 ms 2004 KB Output is correct
6 Correct 3 ms 2004 KB Output is correct
7 Correct 2 ms 2004 KB Output is correct
8 Correct 2 ms 2048 KB Output is correct
9 Correct 3 ms 2004 KB Output is correct
10 Correct 2 ms 2004 KB Output is correct
11 Correct 2 ms 2004 KB Output is correct
12 Correct 184 ms 4752 KB Output is correct
13 Correct 137 ms 4760 KB Output is correct
14 Correct 122 ms 4636 KB Output is correct
15 Correct 125 ms 4880 KB Output is correct
16 Correct 137 ms 4632 KB Output is correct
17 Correct 16 ms 2392 KB Output is correct
18 Correct 78 ms 3744 KB Output is correct
19 Correct 52 ms 3100 KB Output is correct
20 Correct 51 ms 3088 KB Output is correct
21 Correct 28 ms 2628 KB Output is correct
22 Correct 97 ms 4140 KB Output is correct
23 Correct 84 ms 3404 KB Output is correct
24 Correct 63 ms 3352 KB Output is correct