QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#825124 | #9774. Same Sum | ucup-team5243# | WA | 1ms | 3756kb | C++17 | 3.7kb | 2024-12-21 17:26:12 | 2024-12-21 17:26:13 |
Judging History
你现在查看的是最新测评结果
- [2025-01-11 11:59:18]
- hack成功,自动添加数据
- (/hack/1443)
- [2024-12-23 17:02:06]
- hack成功,自动添加数据
- (/hack/1310)
- [2024-12-23 16:48:26]
- hack成功,自动添加数据
- (/hack/1309)
- [2024-12-23 16:33:45]
- hack成功,自动添加数据
- (/hack/1308)
- [2024-12-23 16:23:53]
- hack成功,自动添加数据
- (/hack/1307)
- [2024-12-23 16:13:08]
- hack成功,自动添加数据
- (/hack/1306)
- [2024-12-23 15:54:42]
- hack成功,自动添加数据
- (/hack/1305)
- [2024-12-23 14:58:39]
- hack成功,自动添加数据
- (/hack/1304)
- [2024-12-23 09:58:11]
- hack成功,自动添加数据
- (/hack/1302)
- [2024-12-23 09:47:22]
- hack成功,自动添加数据
- (/hack/1301)
- [2024-12-23 09:41:23]
- hack成功,自动添加数据
- (/hack/1300)
- [2024-12-23 09:26:32]
- hack成功,自动添加数据
- (/hack/1299)
- [2024-12-23 09:19:58]
- hack成功,自动添加数据
- (/hack/1298)
- [2024-12-23 09:13:29]
- hack成功,自动添加数据
- (/hack/1297)
- [2024-12-22 18:52:18]
- hack成功,自动添加数据
- (/hack/1296)
- [2024-12-22 18:13:14]
- hack成功,自动添加数据
- (/hack/1294)
- [2024-12-21 17:26:12]
- 提交
answer
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;
string trans(string a, string b, string c){
string res;
for(char x : a){
if(x == '0') res += b;
else res += c;
}
return res;
}
vector<string> solve(i64 a, i64 b, i64 c){
if(a == b && b == c){
if(a == 1) return { "0", "0", "0" };
if(a == 2) return {};
string F = string(a, '0'); F[a-1] = '1';
string G = string(a, '0'); G[a-2] = '1';
string H = string(a, '0'); H[a-2] = H[a-1] = '1';
return { F, G, H };
}
if(b > c){
auto X = solve(a,c,b);
if(X.empty()) return {};
return { X[0], X[2], X[1] };
}
if(a > c){
auto X = solve(c,b,a);
if(X.empty()) return {};
return { X[2], X[1], X[0] };
}
vector<string> ans;
{
i64 g = gcd(gcd(a,b), c);
if(g != 1){
auto X = solve(a/g, b/g, c/g);
if(X.empty()) return {};
string F = string(g, '0'); F[g-1] = '1';
string G = string(g, '1'); G[g-1] = '0';
ans.push_back(trans(X[0], F, G));
ans.push_back(trans(X[1], F, G));
ans.push_back(trans(X[2], string(g,'0'), string(g,'1')));
return ans;
}
}
rep(t,3) ans.push_back("0");
rep(t,3){
if(a != gcd(a,b) * gcd(a,c)) return {};
i64 g = gcd(a,b);
if(g != 1){
//string F = string(g, '0'); F[g-1] = '1';
//string G = string(g, '1'); G[g-1] = '0';
auto x = ans[0];
auto y = ans[1];
rep(i,g-1) ans[0] += x;
rep(i,g-1) ans[1] += y;
rep(s,2) rep(i,ans[s].size()) if(i % g == 0) ans[s][i] ^= '0' ^ '1';
}
swap(ans[0], ans[1]); swap(ans[1], ans[2]);
swap(a,b); swap(b,c);
}
return ans;
}
void testcase(){
i64 a,b,c; cin >> a >> b >> c;
auto ans = solve(a,b,c);
if(ans.empty()){
cout << "NO\n";
} else {
cout << "YES\n";
rep(t,3) cout << ans[t] << "\n";
}
}
bool test_period(const string& s){
int n = s.size();
for(int i=1; i<n; i++) if(n%i == 0){
bool q = true;
rep(t,n-i) if(s[t] != s[i+t]){ q = false; break; }
if(q) return false;
}
return true;
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
i64 T; cin >> T;
rep(t,T)
testcase();
//for(i64 a=1; a<=20; a++)for(i64 b=1; b<=20; b++)for(i64 c=1; c<=20; c++){
// auto X = solve(a,b,c);
// if(!X.empty()){
// bool ok = true;
// rep(f,3){
// if(!test_period(X[f])){
// cout << a << " " << b << " " << c << endl;
// rep(q,3) cout << X[q] << endl;
// exit(0);
// }
// }
// i64 L = lcm(lcm(a,b),c);
// rep(l,L){
// int t = (X[0][l%a]-'0') ^ (X[1][l%b]-'0') ^ (X[2][l%c]-'0');
// if(t == 1){
// cout << a << " " << b << " " << c << endl;
// rep(q,3) cout << X[q] << endl;
// exit(0);
// }
// }
// }
//}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3756kb
input:
8 4 1 2 3 4 5 6 7 8 2 1 8 1 1 4 4 2 1 6 2 1 8
output:
NO NO NO NO NO NO NO NO
result:
wrong answer expected YES, found NO [1st token]