QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#180133 | #5682. PSET | Yshanqian | RE | 0ms | 0kb | C++14 | 1.6kb | 2023-09-15 15:57:02 | 2023-09-15 15:57:02 |
answer
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define xx first
#define yy second
#define endl "\n"
#define lowbit(x) x & (-x)
#define int long long
#define ull unsigned long long
#define pb push_back
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define Ysanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 18446, P = 13331;
const double eps = 1e-8;
int n, ans;
string s, p;
struct node
{
string s, p;
} a[N];
bool judge(string a, string b, string c)
{
set<char> s[10];
for (int i = 0; i < 4; i++)
s[i].insert(a[i]), s[i].insert(b[i]), s[i].insert(c[i]);
for (int i = 0; i < 4; i++)
if (s[i].size() == 2)
return false;
return true;
}
bool check(node a, node b, node c)
{
string s[3] = {a.s, b.s, c.s};
string p[3] = {a.p, b.p, c.p};
for (int i = 0; i < (1 << 3); i++)
{
for (int j = 0; j < 3; j++)
if (i >> j & 1)
{
swap(s[i], p[i]);
if (judge(s[0], s[1], s[2]) && judge(p[0], p[1], p[2]))
return true;
swap(s[i], p[i]);
}
}
return false;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].s >> a[i].p;
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
for (int k = j + 1; k <= n; k++)
if (check(a[i], a[j], a[k]))
ans++;
cout << ans << endl;
}
signed main()
{
Ysanqian;
int T;
T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
4 3BFD 1RED 1GSA 3GSO 3REA 1BFO 2REO 2BFA