#include<iostream>
using namespace std;
int ab[30][30]; //gora
int cd[30][30]; //dol
int ac[30][30]; //lewo
int bd[30][30]; //prawo
int abc[30][30][30]; //gora lewo
int abd[30][30][30]; //gora prawo
int acd[30][30][30]; //dol lewo
int bcd[30][30][30]; //dol prawo
int abcd[30][30][30][30];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,sum=0,v1,v2,v3,v4;
string s1,s2;
cin>>n;
for(int i=0;i<n;i++){
cin>>s1>>s2;
v1=s1[0]-'A';
v2=s1[1]-'A';
v3=s2[0]-'A';
v4=s2[1]-'A';
//cout<<sum<<' ';
sum+=ab[v3][v4];
//cout<<sum<<' ';
sum+=cd[v1][v2];
//cout<<sum<<' ';
sum+=ac[v2][v4];
//cout<<sum<<' ';
sum+=bd[v1][v3];
//cout<<sum<<' ';
sum-=abcd[v3][v4][v1][v2];
//cout<<sum<<' ';
if(v2==v3)sum-=abc[v2][v4][v4];
//cout<<sum<<' ';
if(v1==v4)sum-=abd[v3][v1][v3];
//cout<<sum<<' ';
if(v1==v4)sum-=acd[v2][v1][v2];
//cout<<sum<<' ';
if(v2==v3)sum-=bcd[v1][v1][v3];
//cout<<sum<<' ';
sum-=abcd[v2][v1][v4][v3];
//cout<<sum<<'\n';
abcd[v1][v2][v3][v4]=1;
ab[v1][v2]++;
cd[v3][v4]++;
ac[v1][v3]++;
bd[v2][v4]++;
abc[v1][v2][v3]++;
abd[v1][v2][v4]++;
acd[v1][v3][v4]++;
bcd[v2][v3][v4]++;
}
cout<<sum;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
724 KB |
Output is correct |
4 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
724 KB |
Output is correct |
4 |
Correct |
1 ms |
852 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
3564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
14 ms |
3380 KB |
Output is correct |
3 |
Correct |
56 ms |
4920 KB |
Output is correct |
4 |
Correct |
28 ms |
4184 KB |
Output is correct |
5 |
Correct |
35 ms |
4180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |