QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#98811#6309. AqreAFewSunsWA 2ms3404kbC++142.0kb2023-04-20 09:11:292023-04-20 09:11:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-20 09:11:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3404kb
  • [2023-04-20 09:11:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
ll t,n,m,a[1010][1010];
ll f[5][5]={{0,0,0,0,0},{0,2,4,3,1},{0,3,1,4,2},{0,4,2,3,1},{0,1,3,2,4}},b[5];
int main(){
	t=read();
	while(t--){
		bl rev=0;
		n=read();
		m=read();
		if(n>m){
			swap(n,m);
			rev=1;
		}
		fr(i,1,n) fr(j,1,m) a[i][j]=1;
		if(m>3){
			fr(i,1,4) b[i]=f[(m-1)%4+1][i];
			if(m%4==1&&n%4==1){
				fr(i,1,4) b[i]=f[1][i%4+1];
			}
			fr(i,1,n) for(ll j=b[(i-1)%4+1];j<=m;j+=4) a[i][j]=0;
			if(m%4==2&&n>2&&n%4==2){
				fr(i,1,m) a[n][i]=1;
				for(ll i=b[3];i<=m;i+=4) a[n][i]=0;
			}
		}
		ll ans=0;
		fr(i,1,n) fr(j,1,m) ans+=a[i][j];
		writeln(ans);
		if(rev){
			fr(j,1,m){
				fr(i,1,n) write(a[i][j]);
				enter;
			}
		}
		else{
			fr(i,1,n){
				fr(j,1,m) write(a[i][j]);
				enter;
			}
		}
	}
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3312kb

input:

3
2 2
3 4
3 8

output:

4
11
11
9
0111
1101
1011
18
01110111
11011101
10111011

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3404kb

input:

361
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
4 13
4 14
4 15
4 16
4 17
4 18
4 19
4 20
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 1...

output:

4
11
11
6
111
111
6
0111
1101
8
10111
11101
9
110111
011101
11
1110111
1011101
12
01110111
11011101
14
101110111
111011101
15
1101110111
0111011101
17
11101110111
10111011101
18
011101110111
110111011101
20
1011101110111
1110111011101
21
11011101110111
01110111011101
23
111011101110111
1011101110111...

result:

wrong answer ans finds a larger answer (test case 25)