Submission #501896

#TimeUsernameProblemLanguageResultExecution timeMemory
501896vrohakCards (LMIO19_korteles)C++14
100 / 100
69 ms11704 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 5 * 1e5; long long int x, a[27][27], b[27][27], c[27][27], d[27][27], ab[27][27][27], ad[27][27][27], bc[27][27][27], cd[27][27][27], k, l, m, n; int abcd[27][27][27][27], ac[27][27][27], bd[27][27][27]; char cards[MAXN][4][4]; long long int sol = 0; int main() { cin >> x; for (int i = 0; i < x; i++) { scanf("%s", cards[i][0]); scanf("%s", cards[i][1]); } for (int i = 0; i < x; i++) { k = cards[i][0][0] - 'A'; l = cards[i][0][1] - 'A'; m = cards[i][1][0] - 'A'; n = cards[i][1][1] - 'A'; sol += c[k][m] + d[m][n] + a[l][n] + b[k][l] - (n == k ? ab[l][n][l] : 0) - (l == m ? (ad[n][l][n] + bc[k][l][k]) : 0) - (k == n ? cd[m][k][m] : 0) + ((k == n && l == m) ? abcd[l][k][n][m] : -abcd[m][n][k][l] - abcd[l][k][n][m]); // cout << ab[l][n][l] << ' ' << ad[n][l][n] << ' ' << bc[k][l][k] << ' ' // << cd[m][k][m] << endl; a[k][m]++; b[m][n]++; c[l][n]++; d[k][l]++; ab[k][m][n]++; ad[l][k][m]++; bc[m][n][l]++; cd[n][l][k]++; abcd[k][l][m][n]++; } cout << sol; return 0; }

Compilation message (stderr)

korteles.cpp: In function 'int main()':
korteles.cpp:16:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |       scanf("%s", cards[i][0]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
korteles.cpp:17:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |       scanf("%s", cards[i][1]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...