제출 #501907

#제출 시각아이디문제언어결과실행 시간메모리
501907vrohakCards (LMIO19_korteles)C++14
100 / 100
71 ms11876 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5 * 1e5;

long long int 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];
int abcd[27][27][27][27], ac[27][27][27], bd[27][27][27], x, y, z, w, n;
char cards[MAXN][4][4];
long long int sol = 0;

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      scanf("%s", cards[i][0]);
      scanf("%s", cards[i][1]);
   }
   for (int i = 0; i < n; i++) {
      x = cards[i][0][0] - 'A';
      y = cards[i][0][1] - 'A';
      z = cards[i][1][0] - 'A';
      w = cards[i][1][1] - 'A';

      sol += a[w][z] + b[y][w] + c[x][y] + d[z][x];
      sol -= abcd[w][z][x][y];
      sol -= abcd[x][y][w][z];

      if (y == z) {
         sol -= ab[w][z][w];
         sol -= cd[x][y][x];
      }

      if (x == w) {
         sol -= ad[z][x][z];
         sol -= bc[y][w][y];
      }

      if (y == z && w == x) sol += 3 * abcd[x][z][x][z];

      a[y][x]++;
      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]++;
      abcd[y][x][z][w]++;
   }
   cout << sol;
   return 0;
}

컴파일 시 표준 에러 (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...