# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
719726 |
2023-04-06T14:24:33 Z |
pashka |
Cards (LMIO19_korteles) |
C++14 |
|
1000 ms |
54588 KB |
#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) {
unordered_map<long, int> m1;
unordered_map<long, int> m2;
long res = 0;
for (int i = 0; i < (int) a.size(); i++) {
long s1 = 0, s2 = 0;
for (auto [x, y]: p) {
s1 *= 30;
s2 *= 30;
s1 += a[i][x] - 'A';
s2 += a[i][y] - 'A';
}
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);
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
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:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
korteles.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | scanf("%s", buf);
| ~~~~~^~~~~~~~~~~
korteles.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%s", buf);
| ~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
724 KB |
Output is correct |
10 |
Correct |
4 ms |
636 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1029 ms |
54588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
113 ms |
11748 KB |
Output is correct |
3 |
Correct |
682 ms |
39772 KB |
Output is correct |
4 |
Correct |
439 ms |
31664 KB |
Output is correct |
5 |
Correct |
462 ms |
31604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
724 KB |
Output is correct |
6 |
Correct |
4 ms |
636 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Execution timed out |
1029 ms |
54588 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |