# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
501915 |
2022-01-04T19:18:37 Z |
vrohak |
Cards (LMIO19_korteles) |
C++14 |
|
55 ms |
4936 KB |
#include <bits/stdc++.h>
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define siz size()
#define pri(i, poc, n, pov) for(int i = (int) poc; i < (int) n; i += (int) pov)
#define od(i, poc, n, pov) for(int i = (int) poc; i > (int) n; i -= (int) pov)
using namespace std;
const ll INF = 1e18;
const int LOG = 20;
const int OFF = (1 << LOG);
const int MOD = 1e9 + 7;
const int lx[8] = {1, -1, 0, 0, -1, 1, 1, -1};
const int ly[8] = {0, 0, 1, -1, -1, 1, -1, 1};
const int N = 1e5 + 10;
int abs(int x){
if(x < 0)
return -x;
return x;
}
ll a[27][27], b[27][27], c[27][27], d[27][27];
ll bc[27][27][27], cd[27][27][27], ad[27][27][27], ab[27][27][27];
ll all[27][27][27][27];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
setprecision(9);
int n;
cin >> n;
ll ans = 0;
pri(i, 0, n, 1){
char s1, s2, s3, s4;
cin >> s1 >> s2 >> s3 >> s4;
int x = s1 - 'A';
int y = s2 - 'A';
int z = s3 - 'A';
int w = s4 - 'A';
ans += c[x][y] + d[z][x] + a[z][w] + b[y][w];
if(y == z){
ans -= ab[w][z][w];
ans -= cd[x][y][x];
}
if(x == w){
ans -= bc[y][w][y];
ans -= ad[z][x][z];
}
if(x == w && y == z) ans += 3 * all[x][y][x][y];
ans -= all[w][z][x][y];
ans -= all[x][y][w][z];
a[x][y]++;
b[x][z]++;
c[z][w]++;
d[w][y]++;
ab[y][x][z]++;
ad[w][y][x]++;
bc[x][z][w]++;
cd[z][w][y]++;
all[y][x][z][w]++;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
844 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
1 ms |
972 KB |
Output is correct |
8 |
Correct |
2 ms |
4428 KB |
Output is correct |
9 |
Correct |
2 ms |
2636 KB |
Output is correct |
10 |
Correct |
2 ms |
3404 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
4812 KB |
Output is correct |
2 |
Correct |
45 ms |
4876 KB |
Output is correct |
3 |
Correct |
41 ms |
4812 KB |
Output is correct |
4 |
Correct |
40 ms |
4812 KB |
Output is correct |
5 |
Correct |
55 ms |
4936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
4852 KB |
Output is correct |
3 |
Correct |
33 ms |
4840 KB |
Output is correct |
4 |
Correct |
24 ms |
4844 KB |
Output is correct |
5 |
Correct |
19 ms |
4844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
1 ms |
972 KB |
Output is correct |
4 |
Correct |
2 ms |
4428 KB |
Output is correct |
5 |
Correct |
2 ms |
2636 KB |
Output is correct |
6 |
Correct |
2 ms |
3404 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
844 KB |
Output is correct |
12 |
Correct |
44 ms |
4812 KB |
Output is correct |
13 |
Correct |
45 ms |
4876 KB |
Output is correct |
14 |
Correct |
41 ms |
4812 KB |
Output is correct |
15 |
Correct |
40 ms |
4812 KB |
Output is correct |
16 |
Correct |
55 ms |
4936 KB |
Output is correct |
17 |
Correct |
7 ms |
4852 KB |
Output is correct |
18 |
Correct |
33 ms |
4840 KB |
Output is correct |
19 |
Correct |
24 ms |
4844 KB |
Output is correct |
20 |
Correct |
19 ms |
4844 KB |
Output is correct |
21 |
Correct |
11 ms |
4812 KB |
Output is correct |
22 |
Correct |
33 ms |
4884 KB |
Output is correct |
23 |
Correct |
28 ms |
4812 KB |
Output is correct |
24 |
Correct |
21 ms |
4812 KB |
Output is correct |