QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#825531 | #9768. A + B = C Problem | ucup-team296# | WA | 0ms | 3536kb | C++20 | 4.3kb | 2024-12-21 20:05:43 | 2024-12-21 20:05:43 |
Judging History
answer
#include <bits/stdc++.h>
#define long long long int
#define DEBUG
using namespace std;
// @author: pashka
struct test {
void check(string s) {
int n = s.size();
for (int k = 1; k < n; k++) {
if (n % k != 0) continue;
bool ok = true;
for (int i = 0; i + k < n; i++) {
if (s[i] != s[i + k]) ok = false;
}
assert(!ok);
}
}
bool check(string a, string b, string c) {
// check(a);
// check(b);
// check(c);
int k = lcm(a.size(), b.size());
k = lcm(k, c.size());
for (int i = 0; i < k; i++) {
if ((a[i % a.size()] - '0') ^ (b[i % b.size()] - '0') ^ (c[i % c.size()] - '0') != 0) {
return true;
}
}
return false;
}
void solve() {
vector<long> a(3);
cin >> a[0] >> a[1] >> a[2];
if (a[0] == a[1] && a[0] == a[2]) {
if (a[0] == 2) {
cout << "NO\n";
return;
}
cout << "YES\n";
for (int i = 0; i < a[0]; i++) {
cout << (i == 0);
}
cout << "\n";
for (int i = 0; i < a[0]; i++) {
cout << (i == 1);
}
cout << "\n";
for (int i = 0; i < a[0]; i++) {
cout << (i <= 1);
}
cout << "\n";
return;
}
for (int j = 0; j < 3; j++) {
int x = (j + 1) % 3;
int y = (j + 2) % 3;
if (a[x] == a[y]) continue;
if (a[j] == a[x] / gcd(a[x], a[y]) * a[y]) {
vector<string> res(3);
for (int i = 0; i < a[x]; i++) {
res[x] += '0' + (i == 0);
}
for (int i = 0; i < a[y]; i++) {
res[y] += '0' + (i == 0);
}
for (int i = 0; i < a[j]; i++) {
res[j] += '0' + ((i % a[x] == 0) ^ (i % a[y] == 0));
}
if (check(res[0], res[1], res[2])) {
cout << "YES\n" << res[0] << "\n" << res[1] << "\n" << res[2] << "\n";
return;
}
}
if (a[x] % 2 == 0 && a[y] % 2 == 0 && a[j] == a[x] / gcd(a[x], a[y]) * a[y] / 2) {
vector<string> res(3);
for (int i = 0; i < a[x]; i++) {
res[x] += '0' + (i < a[x] / 2);
}
for (int i = 0; i < a[y]; i++) {
res[y] += '0' + (i < a[y] / 2);
}
for (int i = 0; i < a[j]; i++) {
res[j] += '0' + ((i % a[x] < a[x] / 2) ^ (i % a[y] < a[y] / 2));
}
if (check(res[0], res[1], res[2])) {
cout << "YES\n" << res[0] << "\n" << res[1] << "\n" << res[2] << "\n";
return;
}
}
if (a[x] % 4 == 0 && a[y] % 4 == 0 && a[j] == a[x] / gcd(a[x], a[y]) * a[y] / 4) {
vector<string> res(3);
for (int i = 0; i < a[x] / 2; i++) {
res[x] += '0' + (i == 0 || i == a[x] / 2 - 1);
}
for (int i = 0; i < a[x] / 2; i++) {
res[x] += res[x][i] ^ 1;
}
for (int i = 0; i < a[y] / 4; i++) {
res[y] += '0';
}
for (int i = 0; i < a[y] / 4; i++) {
res[y] += '0' + (i % 2);
}
for (int i = 0; i < a[y] / 2; i++) {
res[y] += res[y][i] ^ 1;
}
for (int i = 0; i < a[j]; i++) {
res[j] += '0' + ((res[x][i % a[x]] - '0') ^ (res[y][i % a[y]] - '0'));
}
if (check(res[0], res[1], res[2])) {
cout << "YES\n" << res[0] << "\n" << res[1] << "\n" << res[2] << "\n";
return;
}
}
}
cout << "NO\n";
}
};
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
test().solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3536kb
input:
2 2 3 6 2 3 5
output:
NO NO
result:
wrong answer Jury has the answer but participant has not (test case 1)