Submission #719719

#TimeUsernameProblemLanguageResultExecution timeMemory
719719pashkaCards (LMIO19_korteles)C++14
16 / 100
5 ms468 KiB
#include <bits/stdc++.h> #define long long long int #define DEBUG using namespace std; // @author: pashka long calc(vector<string> &a, vector<pair<int, int>> p) { map<string, int> m1; map<string, int> m2; long res = 0; for (int i = 0; i < (int) a.size(); i++) { string s1, s2; for (auto [x, y]: p) { s1 += a[i][x]; s2 += a[i][y]; } res += m2[s1]; res += m1[s2]; m1[s1]++; m2[s2]++; } cerr << res << "\n"; return res; } char buf[10]; int main() { ios::sync_with_stdio(false); int n; scanf("%d", &n); cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) { string x, y; scanf("%s", buf); x = buf; scanf("%s", buf); y = buf; a[i] = x + y; } long res = 0; res += calc(a, {{0, 2}, {1, 3}}); res += calc(a, {{0, 1}, {2, 3}}); res -= calc(a, {{0, 2}, {1, 3}, {2, 0}, {3, 1}}) / 2; res -= calc(a, {{0, 1}, {2, 3}, {1, 0}, {3, 2}}) / 2; res -= calc(a, {{0, 2}, {1, 3}, {1, 0}, {3, 2}}); res -= calc(a, {{0, 2}, {1, 3}, {0, 1}, {2, 3}}); vector<string> a3; for (string s: a) { if (s[0] == s[3] && s[1] == s[2]) a3.push_back(s); } res += calc(a3, {{0, 2}, {1, 3}}) / 2 * 3; cout << res << "\n"; return 0; }

Compilation message (stderr)

korteles.cpp: In function 'long long int calc(std::vector<std::__cxx11::basic_string<char> >&, std::vector<std::pair<int, int> >)':
korteles.cpp:16:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |         for (auto [x, y]: p) {
      |                   ^
korteles.cpp: In function 'int main()':
korteles.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
korteles.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%s", buf);
      |         ~~~~~^~~~~~~~~~~
korteles.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%s", buf);
      |         ~~~~~^~~~~~~~~~~
#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...