#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
string Hash (char a, char b) {
return ((string)"" + a) + b;
}
signed main () {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
int ans = 0;
unordered_map<string,int> mp[1<<4];
for (int i = 0 ; i < n ; i++) {
char a, b, c, d;
cin >> a >> b >> c >> d;
string H[4] = {Hash(a, b), Hash(b, d), Hash(c, d), Hash(a, c)};
// U R D L
vector<string> inc;
string enc, ienc;
int cnt = 0;
int inv = 0;
#define check(j,i,k) if (j & (1 << i)) { cnt++; enc += H[i]; inv |= (1 << k);}
for (int j = 1 ; j < (1 << 4) ; j++) {
enc.clear();
ienc.clear();
cnt = 0;
inv = 0;
check(j, 0, 2);
check(j, 1, 3);
check(j, 2, 0);
check(j, 3, 1);
for (int k = 0 ; k < 4 ; k++) {
if (inv & (1 << k)) {
ienc += H[(k + 2) % 4];
}
}
if (cnt & 1) ans += mp[inv][ienc];
else ans -= mp[inv][ienc];
// cerr << enc << endl;
inc.push_back(enc);
}
for (int j = 1 ; j < (1 << 4) ; j++) mp[j][inc[j - 1]]++;
}
cout << ans << endl;
}
Compilation message
korteles.cpp:14:1: warning: multi-line comment [-Wcomment]
14 | //\
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
5 ms |
1492 KB |
Output is correct |
7 |
Correct |
8 ms |
2004 KB |
Output is correct |
8 |
Correct |
19 ms |
4240 KB |
Output is correct |
9 |
Correct |
22 ms |
3616 KB |
Output is correct |
10 |
Correct |
20 ms |
3540 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1091 ms |
99876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
735 ms |
62352 KB |
Output is correct |
3 |
Execution timed out |
1104 ms |
97128 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
5 ms |
1492 KB |
Output is correct |
3 |
Correct |
8 ms |
2004 KB |
Output is correct |
4 |
Correct |
19 ms |
4240 KB |
Output is correct |
5 |
Correct |
22 ms |
3616 KB |
Output is correct |
6 |
Correct |
20 ms |
3540 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Execution timed out |
1091 ms |
99876 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |