Submission #595522

# Submission time Handle Problem Language Result Execution time Memory
595522 2022-07-13T19:30:59 Z AdamGS Cards (LMIO19_korteles) C++17
100 / 100
50 ms 6604 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
ll ile1[26][26][4], ile2[26][26][4], ile[26][26][26][26], ans;
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  while(n--) {
    char c1, c2, c3, c4;
    cin >> c1 >> c2 >> c3 >> c4;
    int a=c1-'A', b=c2-'A', c=c4-'A', d=c3-'A';
    ans+=ile1[a][b][2]+ile1[d][c][0]+ile1[a][d][1]+ile1[b][c][3];
    ans-=ile[d][c][b][a]+ile[b][a][d][c];
    if(a==c) ans-=ile2[a][b][0]+ile2[c][d][2];
    if(b==d) ans-=ile2[b][c][1]+ile2[d][a][3];
    if(a==c && b==d) ans+=3*ile[b][a][b][a];
    ++ile1[a][b][0]; ++ile1[d][c][2]; ++ile1[a][d][3]; ++ile1[b][c][1];
    ++ile[a][b][c][d];
    if(a==c) {
      ++ile2[d][a][0];
      ++ile2[b][a][2];
    }
    if(b==d) {
      ++ile2[a][b][1];
      ++ile2[c][b][3];
    }
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 2 ms 2004 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 3 ms 3668 KB Output is correct
9 Correct 2 ms 2004 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 6600 KB Output is correct
2 Correct 39 ms 6604 KB Output is correct
3 Correct 50 ms 6484 KB Output is correct
4 Correct 43 ms 6564 KB Output is correct
5 Correct 42 ms 6472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 8 ms 4052 KB Output is correct
3 Correct 27 ms 5524 KB Output is correct
4 Correct 16 ms 4916 KB Output is correct
5 Correct 16 ms 4896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 2 ms 2004 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 3 ms 3668 KB Output is correct
5 Correct 2 ms 2004 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 37 ms 6600 KB Output is correct
13 Correct 39 ms 6604 KB Output is correct
14 Correct 50 ms 6484 KB Output is correct
15 Correct 43 ms 6564 KB Output is correct
16 Correct 42 ms 6472 KB Output is correct
17 Correct 8 ms 4052 KB Output is correct
18 Correct 27 ms 5524 KB Output is correct
19 Correct 16 ms 4916 KB Output is correct
20 Correct 16 ms 4896 KB Output is correct
21 Correct 11 ms 4436 KB Output is correct
22 Correct 33 ms 5960 KB Output is correct
23 Correct 29 ms 5196 KB Output is correct
24 Correct 20 ms 5156 KB Output is correct