#include <bits/stdc++.h>
using namespace std;
int L[27][27];
int D[27][27];
int G[27][27];
int P[27][27];
int LD[27][27][27][27];
int LP[27][27][27][27];
int LG[27][27][27][27];
int PD[27][27][27][27];
int PG[27][27][27][27];
int DG[27][27][27][27];
int LPDG[27][27];
int f(int a,int b,int c,int d)
{
int w=0;
w=L[b][d]+P[a][c]+D[a][b]+G[c][d]-LD[b][d][a][b]-LP[b][d][a][c]-LG[b][d][c][d]-PD[a][c][a][b]-PG[a][c][c][d]-DG[a][b][c][d];
if(a==d&&b==c)w+=3*LPDG[c][d];
return w;
}
void dodaj(int a,int b,int c,int d)
{
L[a][c]++;
P[b][d]++;
D[c][d]++;
G[a][b]++;
LP[a][c][b][d]++;
LD[a][c][c][d]++;
LG[a][c][a][b]++;
PD[b][d][c][d]++;
PG[b][d][a][b]++;
DG[c][d][a][b]++;
if(a==d&&b==c)LPDG[a][b]++;
}
int main()
{
int n;
cin>>n;
long long w=0;
for(int i=0;i<n;i++)
{
char x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int a=x1-'A',b=y1-'A',c=x2-'A',d=y2-'A';
w+=f(a,b,c,d);
dodaj(a,b,c,d);
}
cout<<w;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
2 ms |
1364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
2 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
5 ms |
8660 KB |
Output is correct |
7 |
Correct |
2 ms |
2260 KB |
Output is correct |
8 |
Correct |
7 ms |
11988 KB |
Output is correct |
9 |
Correct |
5 ms |
7892 KB |
Output is correct |
10 |
Correct |
6 ms |
10324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
14944 KB |
Output is correct |
2 |
Correct |
185 ms |
14936 KB |
Output is correct |
3 |
Correct |
180 ms |
14924 KB |
Output is correct |
4 |
Correct |
172 ms |
14940 KB |
Output is correct |
5 |
Correct |
190 ms |
14936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
33 ms |
12412 KB |
Output is correct |
3 |
Correct |
124 ms |
13812 KB |
Output is correct |
4 |
Correct |
75 ms |
13164 KB |
Output is correct |
5 |
Correct |
74 ms |
13164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
8660 KB |
Output is correct |
3 |
Correct |
2 ms |
2260 KB |
Output is correct |
4 |
Correct |
7 ms |
11988 KB |
Output is correct |
5 |
Correct |
5 ms |
7892 KB |
Output is correct |
6 |
Correct |
6 ms |
10324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
2 ms |
1364 KB |
Output is correct |
12 |
Correct |
182 ms |
14944 KB |
Output is correct |
13 |
Correct |
185 ms |
14936 KB |
Output is correct |
14 |
Correct |
180 ms |
14924 KB |
Output is correct |
15 |
Correct |
172 ms |
14940 KB |
Output is correct |
16 |
Correct |
190 ms |
14936 KB |
Output is correct |
17 |
Correct |
33 ms |
12412 KB |
Output is correct |
18 |
Correct |
124 ms |
13812 KB |
Output is correct |
19 |
Correct |
75 ms |
13164 KB |
Output is correct |
20 |
Correct |
74 ms |
13164 KB |
Output is correct |
21 |
Correct |
44 ms |
12856 KB |
Output is correct |
22 |
Correct |
155 ms |
14296 KB |
Output is correct |
23 |
Correct |
102 ms |
13528 KB |
Output is correct |
24 |
Correct |
116 ms |
13532 KB |
Output is correct |