QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#883180#9768. A + B = C ProblemscallionsongWA 2ms8172kbC++173.9kb2025-02-05 15:05:212025-02-05 15:05:22

Judging History

This is the latest submission verdict.

  • [2025-02-05 15:05:22]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 8172kb
  • [2025-02-05 15:05:21]
  • Submitted

answer

bool M1;
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define LL __int128
#define db double
#define LD long double
#define Pii pair<int,int>
#define Pll pair<ll,ll>
#define Pull pair<ull,ull>
#define Pdb pair<db,db>
#define fir first
#define sec second
#define vec vector<int>
#define pb push_back
#define qlr cerr<<"qlr\n"
#define dyh cerr<<"dyh\n"
#define pc(x) __builtin_popcount(x)
#define uni(x,y) uniform_int_distribution<int>(x,y)(rng)
#define unl(x,y) uniform_int_distribution<ll>(x,y)(rng)
#define unr(x,y) uniform_real_distribution<double>(x,y)(rng)
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define look_memory cerr<<'\n'<<abs(&M1-&M2)/1024.0/1024<<'\n'
#define look_time cerr<<'\n'<<clock()*1.0/CLOCKS_PER_SEC<<'\n'
mt19937 rng(time(0)^(*new int));
const ll INF=0x3f3f3f3f3f3f3f3f;
const int Mod=1e9+7;
template<typename T>
inline void inc(T &a,T b){
	if(b<0) b+=Mod;
	a+=b;
	if(a>=Mod) a-=Mod;
}
template<typename T>
inline void dec(T &a,T b){
	if(b<0) b+=Mod;
	a-=b;
	if(a<0) a+=Mod;
}
template<typename T>
inline void muc(T &a,T b){
	a=a*b%Mod;
}
template<typename T>
inline bool chkmin(T &a,T b){
	if(a<=b) return false;
	a=b;
	return true;
}
template<typename T>
inline bool chkmax(T &a,T b){
	if(a>=b) return false;
	a=b;
	return true;
}
int T,TT;
ll A,B,C,g,p,q,r;
int ans1[1000010],ans2[1000010],ans3[1000010];
ll lcm(ll a,ll b){
	return a*b/__gcd(a,b);
}
int P(int x){
	return x<p-1?0:1;
}
int Q(int x){
	return x<q-1?0:1;
}
int R(int x){
	return x<r-1?0:1;
}
void solve(){
	TT++;
	cin>>A>>B>>C;
	if(A==2&&B==2&&C==2){
		cout<<"NO\n";
		return;
	}
	if(lcm(A,B)%C||lcm(A,C)%B||lcm(B,C)%A){
		cout<<"NO\n";
		return;
	}
	g=__gcd(__gcd(A,B),C),p=__gcd(A,B)/g,q=__gcd(A,C)/g,r=__gcd(B,C)/g;
	cout<<p<<' '<<q<<' '<<r<<'\n';
	if(p==1&&q==1&&r==1){
		if(g==1){
			cout<<"YES\n";
			cout<<"0\n";
			cout<<"0\n";
			cout<<"0\n";
		}
		else{
			cout<<"YES\n";
			F(i,1,g-2) cout<<"0";
			cout<<"01\n";
			F(i,1,g-2) cout<<"0";
			cout<<"10\n";
			F(i,1,g-2) cout<<"0";
			cout<<"11\n";
		}
		return;
	}
	if(p==1&&q==1&&r>1){
		F(i,0,A-2) ans1[i]=0;
		ans1[A-1]=1;
		F(i,0,C-2) ans3[i]=0;
		ans3[C-1]=1;
		F(i,0,B-1) ans2[i]=ans1[i%A]^ans3[i%C];
		cout<<"YES\n";
		F(i,0,A-1) cout<<ans1[i];
		cout<<'\n';
		F(i,0,B-1) cout<<ans2[i];
		cout<<'\n';
		F(i,0,C-1) cout<<ans3[i];
		cout<<'\n';
		return;
	}
	if(p==1&&q>1&&r==1){
		F(i,0,A-2) ans1[i]=0;
		ans1[A-1]=1;
		F(i,0,B-2) ans2[i]=0;
		ans2[B-1]=1;
		F(i,0,C-1) ans3[i]=ans1[i%A]^ans2[i%B];
		cout<<"YES\n";
		F(i,0,A-1) cout<<ans1[i];
		cout<<'\n';
		F(i,0,B-1) cout<<ans2[i];
		cout<<'\n';
		F(i,0,C-1) cout<<ans3[i];
		cout<<'\n';
		return;
	}
	if(p>1&&q==1&&r==1){
		F(i,0,B-2) ans2[i]=0;
		ans2[B-1]=1;
		F(i,0,C-2) ans3[i]=0;
		ans3[C-1]=1;
		F(i,0,A-1) ans1[i]=ans2[i%B]^ans3[i%C];
		cout<<"YES\n";
		F(i,0,A-1) cout<<ans1[i];
		cout<<'\n';
		F(i,0,B-1) cout<<ans2[i];
		cout<<'\n';
		F(i,0,C-1) cout<<ans3[i];
		cout<<'\n';
		return;
	}
	assert(__gcd(p,q)==1&&__gcd(p,r)==1&&__gcd(q,r)==1);
	assert(A==g*p*q&&B==g*p*r&&C==g*q*r);
	F(i,0,A-1) ans1[i]=P(i/g%p)^Q(i/g%q);
	F(i,0,B-1) ans2[i]=P(i/g%p)^R(i/g%r);
	F(i,0,C-1) ans3[i]=Q(i/g%q)^R(i/g%r);
	cout<<"YES\n";
	F(i,0,A-1) cout<<ans1[i];
	cout<<'\n';
	F(i,0,B-1) cout<<ans2[i];
	cout<<'\n';
	F(i,0,C-1) cout<<ans3[i];
	cout<<'\n';
}
bool M2;
int main(){
//	freopen("A.in","r",stdin);
//	freopen("A1.out","w",stdout);
	srand(time(0)^(*new int));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	while(T--) solve();
	look_memory;
	look_time;
	return 0;
}
/*
g++ A1.cpp -o A1 -std=c++14 -O2&&./A1

1
4 4 2
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8172kb

input:

2
2 3 6
2 3 5

output:

1 2 3
YES
10
110
011100
NO

result:

wrong answer Expected Yes/No (test case 1)