Submission #713673

#TimeUsernameProblemLanguageResultExecution timeMemory
713673tamyteCards (LMIO19_korteles)C++14
36 / 100
1063 ms16664 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) (int)(x).size() void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } /*----------------------------------*/ vector<int> match[4][26][26]; // 0 - up, 1 - down, 2 - left, 3 - right struct cards { char a, b, c, d; }; int main() { setIO(""); int n; cin >> n; // cout << 'Z' - 65; // return 0; vector<cards> arr(n); for (int i = 0; i < n; ++i) { cin >> arr[i].a >> arr[i].b >> arr[i].c >> arr[i].d; match[0][arr[i].a - 'A'][arr[i].b - 'A'].push_back(i); match[1][arr[i].c - 'A'][arr[i].d - 'A'].push_back(i); match[2][arr[i].a - 'A'][arr[i].c - 'A'].push_back(i); match[3][arr[i].b - 'A'][arr[i].d - 'A'].push_back(i); } reverse(arr.begin(), arr.end()); int ans = 0; for (int i = 0; i < n; ++i) { set<int> st; st.insert(n - i - 1); match[0][arr[i].a - 'A'][arr[i].b - 'A'].pop_back(); match[1][arr[i].c - 'A'][arr[i].d - 'A'].pop_back(); match[2][arr[i].a - 'A'][arr[i].c - 'A'].pop_back(); match[3][arr[i].b - 'A'][arr[i].d - 'A'].pop_back(); for (auto u : match[1][arr[i].a - 'A'][arr[i].b - 'A']) { // cout << u << " "; st.insert(u); } for (auto u : match[0][arr[i].c - 'A'][arr[i].d - 'A']) { // cout << u << " "; st.insert(u); } for (auto u : match[3][arr[i].a - 'A'][arr[i].c - 'A']) { // cout << u << " "; st.insert(u); } for (auto u : match[2][arr[i].b - 'A'][arr[i].d - 'A']) { // cout << u << " "; st.insert(u); } ans += st.size() - 1; } cout << ans; }

Compilation message (stderr)

korteles.cpp: In function 'void setIO(std::string)':
korteles.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
korteles.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...