# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501776 | 2022-01-04T14:43:47 Z | fabijan_cikac | Cards (LMIO19_korteles) | C++17 | 1000 ms | 35584 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int n; map<string, int> m; ll sol = 0; vector<string> v; int dio(string a, string b){ for (int i = 0; i < a.size(); ++i){ if (a[i] != '*' && a[i] != b[i]) return 0; } return 1; } void solve(string a){ for (int i = 1; i < 16; ++i){ string s = "****"; int cnt = 0; for (int j = 0; j < 4; ++j){ if (i & (1 << j)) ++cnt; } if (i & 1){ if ((s[3] != '*' && s[3] != a[0]) || (s[2] != '*' && s[2] != a[1])) continue; s[3] = a[0]; s[2] = a[1]; } if (i & 2){ if ((s[0] != '*' && s[0] != a[1]) || (s[3] != '*' && s[3] != a[2])) continue; s[0] = a[1]; s[3] = a[2]; } if (i & 4){ if ((s[0] != '*' && s[0] != a[3]) || (s[1] != '*' && s[1] != a[2])) continue; s[0] = a[3]; s[1] = a[2]; } if (i & 8){ if ((s[1] != '*' && s[1] != a[0]) || (s[2] != '*' && s[2] != a[3])) continue; s[1] = a[0]; s[2] = a[3]; } if (cnt & 1) sol += (m[s] - dio(s, a)); else sol -= (m[s] - dio(s, a)); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; v.resize(n); for (int i = 0; i < n; ++i){ string b; cin >> v[i] >> b; v[i].push_back(b[1]); v[i].push_back(b[0]); for (int j = 0; j < 16; ++j){ string s; for (int k = 0; k < 4; ++k){ if (j & (1 << k)) s.push_back(v[i][k]); else s.push_back('*'); } ++m[s]; } } for (int i = 0; i < n; ++i) solve(v[i]); cout << sol / 2; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 288 KB | Output is correct |
4 | Correct | 1 ms | 312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 288 KB | Output is correct |
4 | Correct | 1 ms | 312 KB | Output is correct |
5 | Correct | 0 ms | 316 KB | Output is correct |
6 | Correct | 4 ms | 844 KB | Output is correct |
7 | Correct | 7 ms | 588 KB | Output is correct |
8 | Correct | 15 ms | 1996 KB | Output is correct |
9 | Correct | 13 ms | 1344 KB | Output is correct |
10 | Correct | 17 ms | 1356 KB | Output is correct |
11 | Correct | 1 ms | 312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1070 ms | 35584 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 445 ms | 17344 KB | Output is correct |
3 | Execution timed out | 1069 ms | 30852 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 316 KB | Output is correct |
2 | Correct | 4 ms | 844 KB | Output is correct |
3 | Correct | 7 ms | 588 KB | Output is correct |
4 | Correct | 15 ms | 1996 KB | Output is correct |
5 | Correct | 13 ms | 1344 KB | Output is correct |
6 | Correct | 17 ms | 1356 KB | Output is correct |
7 | Correct | 1 ms | 312 KB | Output is correct |
8 | Correct | 1 ms | 292 KB | Output is correct |
9 | Correct | 1 ms | 304 KB | Output is correct |
10 | Correct | 1 ms | 288 KB | Output is correct |
11 | Correct | 1 ms | 312 KB | Output is correct |
12 | Execution timed out | 1070 ms | 35584 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |