# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
657405 |
2022-11-09T19:46:11 Z |
pls33 |
Cards (LMIO19_korteles) |
C++17 |
|
1000 ms |
86148 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma region dalykai
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;
using pf32 = pair<float, float>;
using pf64 = pair<double, double>;
using pf80 = pair<long double, long double>;
using vf32 = vector<float>;
using vf64 = vector<double>;
using vf80 = vector<long double>;
using vpf32 = vector<pf32>;
using vpf64 = vector<pf64>;
using vpf80 = vector<pf80>;
using vvf32 = vector<vf32>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;
using vvpf32 = vector<vpf32>;
using vvpf64 = vector<vpf64>;
using vvpf80 = vector<vpf80>;
template <typename key, typename val>
using ord_map = tree<key, val, less<key>, rb_tree_tag,
tree_order_statistics_node_update>;
template <typename key>
using ord_set = tree<key, null_type, less<key>, rb_tree_tag,
tree_order_statistics_node_update>;
const int BUF_SZ = 1 << 15;
inline namespace fast_in
{
char buf[BUF_SZ];
int pos;
int len;
char next_char(FILE *f)
{
if (pos == len)
{
pos = 0;
len = (int)fread(buf, 1, BUF_SZ, f);
if (!len)
{
return EOF;
}
}
return buf[pos++];
}
int read_int(FILE *f)
{
int x;
char ch;
int sgn = 1;
while (!isdigit(ch = next_char(f)))
{
if (ch == '-')
{
sgn *= -1;
}
}
x = ch - '0';
while (isdigit(ch = next_char(f)))
{
x = x * 10 + (ch - '0');
}
return x * sgn;
}
}
/**
* @brief gale programos flush_out kviest!!
*/
inline namespace fast_out
{
char buf[BUF_SZ];
int pos;
void flush_out(FILE *f)
{
fwrite(buf, 1, pos, f);
pos = 0;
}
void write_char(char c, FILE *f)
{
if (pos == BUF_SZ)
{
flush_out(f);
}
buf[pos++] = c;
}
void write_int(int x, FILE *f)
{
static char num_buf[100];
if (x < 0)
{
write_char('-', f);
x *= -1;
}
int len = 0;
for (; x >= 10; x /= 10)
{
num_buf[len++] = (char)('0' + (x % 10));
}
write_char((char)('0' + x), f);
while (len)
{
write_char(num_buf[--len], f);
}
write_char('\n', f);
}
}
#pragma endregion
struct card_t
{
string s1, s2;
void fix()
{
s1[0] -= 'A';
s1[1] -= 'A';
s2[0] -= 'A';
s2[1] -= 'A';
}
};
using vvi16u = vector<vi16u>;
uint16_t compress(char a, char b, uint16_t dir)
{
return uint16_t(uint16_t(a - 'A') * 1000 +
uint16_t(b - 'A') * 10 +
dir);
}
vi16u get_parts(card_t &card, bool opposite)
{
vi16u opp = opposite ? vi16u{2, 3, 0, 1} : vi16u{0, 1, 2, 3};
return {
compress(card.s1[0], card.s1[1], opp[0]),
compress(card.s1[1], card.s2[1], opp[1]),
compress(card.s2[0], card.s2[1], opp[2]),
compress(card.s1[0], card.s2[0], opp[3])};
}
int main()
{
#ifndef _AAAAAAAAA
ios_base::sync_with_stdio(false);
cin.tie(0);
#else
freopen("cards.in", "r", stdin);
#ifndef __linux__
atexit([]()
{
freopen("con", "r", stdin);
system("pause"); });
#endif
#endif
int n;
cin >> n;
map<uint16_t, set<uint16_t>> common;
vector<card_t> cards(n);
vvi16u parts(n);
vi16u flat;
for (int i = 0; i < n; i++)
{
cin >> cards[i].s1 >> cards[i].s2;
parts[i] = get_parts(cards[i], false);
for (size_t j = 0; j < parts[i].size(); j++)
{
flat.push_back(parts[i][j]);
for (size_t k = 0; k < parts[i].size(); k++)
{
if (j == k)
{
continue;
}
common[parts[i][j]].insert(parts[i][k]);
common[parts[i][k]].insert(parts[i][j]);
}
}
}
map<uint16_t, int64_t> edge_count;
for (auto &i : flat)
{
edge_count[i]++;
}
int64_t total = 0;
for (size_t i = 0; i < cards.size(); i++)
{
auto &card = cards[i];
auto &part = parts[i];
auto opp = get_parts(card, true);
for (auto &p : opp)
{
total += edge_count[p];
total -= find(part.begin(), part.end(), p) != part.end();
}
}
cout << total / 2 << '\n';
return 0;
}
Compilation message
korteles.cpp:8: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
8 | #pragma region dalykai
|
korteles.cpp:151: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
151 | #pragma endregion
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
86148 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 |
Incorrect |
304 ms |
22244 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |