# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713673 | 2023-03-22T19:24:27 Z | tamyte | Cards (LMIO19_korteles) | C++14 | 1000 ms | 16664 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 360 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 380 KB | Output is correct |
7 | Correct | 7 ms | 468 KB | Output is correct |
8 | Correct | 3 ms | 524 KB | Output is correct |
9 | Correct | 16 ms | 504 KB | Output is correct |
10 | Correct | 8 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1047 ms | 16664 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 645 ms | 2260 KB | Output is correct |
3 | Execution timed out | 1063 ms | 9128 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 380 KB | Output is correct |
3 | Correct | 7 ms | 468 KB | Output is correct |
4 | Correct | 3 ms | 524 KB | Output is correct |
5 | Correct | 16 ms | 504 KB | Output is correct |
6 | Correct | 8 ms | 468 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 360 KB | Output is correct |
12 | Execution timed out | 1047 ms | 16664 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |