QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#153655 | #5438. Half Mixed | organput# | WA | 115ms | 3856kb | C++14 | 2.3kb | 2023-08-30 17:02:43 | 2023-08-30 17:02:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fo(x,a,b) for(int x=a;x<=b;x++)
#define of(x,a,b) for(int x=a;x>=b;x--)
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define PI acos(-1)
#define pb push_back
#define INF 0x3f3f3f3f
#define lowbit(a) ((a)&-(a))
#define lbit(a) (__builtin_ffsll(a))
#define ubit(a) (64-__builtin_clzll(a))
#define fi first
#define se second
bool isprime(ll x){
if(x==1)return false;
for(ll i=2;i<=x/i;i++){
if(x%i==0)return false;
}
return true;
}
ll popcnt(ll x){
ll cnt=0;
while(x){
if(x&1)cnt++;
x>>=1;
}
return cnt;
}
ll qmi(ll a,ll b,ll p){
a%=p;
ll res=1;
while(b){
if(b&1)res=res*a%p;
a=a*a%p;
b>>=1;
}
return res;
}
ll exgcd(ll a,ll b,ll &x,ll &y){
if(!b){
x=1,y=0;
return a;
}
ll d=exgcd(b,a%b,y,x);
y-=a/b*x;
return d;
}
const int N=2e5+10;
const int mod=1e9+7;
ll fact[N],in_fact[N];
ll C(ll n,ll m) {
if (n < m || m < 0)return 0;
return fact[n] * qmi(fact[m] * fact[n - m] % mod, mod - 2, mod) % mod;
}
//ll C(ll n,ll m){
// if (n < m || m < 0)return 0;
// return fact[n]%mod*in_fact[m]%mod*in_fact[n-m]%mod;
//}
ll n,m;
string check(ll x,ll y){
int cnt=1;
ll res=(x*x+x)/4-x;
string s="1";
fo(i,0,x-1){
if(res>=(cnt*cnt+cnt)/2 && cnt<=y){
s.push_back(s.back());
res-=cnt;
cnt++;
}
else{
if(s.back()=='0') s.push_back('1');
else s.push_back('0');
cnt=1;
//cout<<s<<endl;
}
}
return s;
}
void sol(){
cin>>n>>m;
if((m*m+m)%4==0){
string s=check(m,n);
cout<<"Yes"<<endl;
fo(i,0,n-1){
fo(j,0,m-1){
cout<<s[j]<<' ';
}
cout<<endl;
}
}
else if((n*n+n)%4==0){
string s=check(n,m);
cout<<"Yes"<<endl;
fo(i,0,n-1){
fo(j,0,m-1){
cout<<s[i]<<' ';
}
cout<<endl;
}
}
else{
cout<<"No"<<endl;
}
}
int main(){
close();
int t=1;
cin>>t;
while(t--){
sol();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3856kb
input:
2 2 3 1 1
output:
Yes 1 0 1 1 0 1 No
result:
ok OK, Accepted. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 115ms
memory: 3612kb
input:
5382 1 1 1 2 2 1 1 3 2 2 3 1 1 4 2 3 3 2 4 1 1 5 2 4 3 3 4 2 5 1 1 6 2 5 3 4 4 3 5 2 6 1 1 7 2 6 3 5 4 4 5 3 6 2 7 1 1 8 2 7 3 6 4 5 5 4 6 3 7 2 8 1 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 9 1 1 10 2 9 3 8 4 7 5 6 6 5 7 4 8 3 9 2 10 1 1 11 2 10 3 9 4 8 5 7 6 6 7 5 8 4 9 3 10 2 11 1 1 12 2 11 3 10 4 9 5 8 6 ...
output:
No No No Yes 1 0 1 No Yes 1 0 1 Yes 1 1 0 1 Yes 1 0 1 1 0 1 Yes 1 1 0 0 1 1 Yes 1 1 0 1 No Yes 1 1 0 1 1 1 0 1 Yes 1 0 1 1 0 1 1 0 1 Yes 1 1 1 1 0 0 1 1 No No No Yes 1 1 0 1 1 1 0 1 1 1 0 1 Yes 1 0 1 1 0 1 1 0 1 1 0 1 No No Yes 1 1 0 0 1 1 0 No Yes 1 1 1 1 1 0 0 0 0 0...
result:
wrong answer 18 Mixed Submatrices Found, but 14 Expected (test case 22)