QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442010#8474. Matrices and Sumsbulijiojiodibuliduo#AC ✓39ms8044kbC++171.0kb2024-06-15 02:35:022024-06-15 02:35:02

Judging History

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

  • [2024-06-15 02:35:02]
  • 评测
  • 测评结果:AC
  • 用时:39ms
  • 内存:8044kb
  • [2024-06-15 02:35:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n,a[1010][1010];
int main() {
	scanf("%d",&n);
	if (n%2==1) {
		puts("No");
		return 0;
	}
	for (int d=0;d<n;d+=2) {
		rep(j,d,n) a[d][j]=1;
		rep(j,d+1,n) a[d+1][j]=-1;
		rep(j,d+2,n) {
			if (j%2==0) a[j][d]=1;
			else a[j][d+1]=-1;
		}
	}
	puts("Yes");
	rep(i,0,n) {
		rep(j,0,n) printf("%d ",a[i][j]); puts("");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4104kb

input:

2

output:

Yes
1 1 
0 -1 

result:

ok OK, Accepted.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3984kb

input:

1

output:

No

result:

ok OK, Accepted.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

3

output:

No

result:

ok OK, Accepted.

Test #4:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

4

output:

Yes
1 1 1 1 
0 -1 -1 -1 
1 0 1 1 
0 -1 0 -1 

result:

ok OK, Accepted.

Test #5:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

5

output:

No

result:

ok OK, Accepted.

Test #6:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

6

output:

Yes
1 1 1 1 1 1 
0 -1 -1 -1 -1 -1 
1 0 1 1 1 1 
0 -1 0 -1 -1 -1 
1 0 1 0 1 1 
0 -1 0 -1 0 -1 

result:

ok OK, Accepted.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

7

output:

No

result:

ok OK, Accepted.

Test #8:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

8

output:

Yes
1 1 1 1 1 1 1 1 
0 -1 -1 -1 -1 -1 -1 -1 
1 0 1 1 1 1 1 1 
0 -1 0 -1 -1 -1 -1 -1 
1 0 1 0 1 1 1 1 
0 -1 0 -1 0 -1 -1 -1 
1 0 1 0 1 0 1 1 
0 -1 0 -1 0 -1 0 -1 

result:

ok OK, Accepted.

Test #9:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

9

output:

No

result:

ok OK, Accepted.

Test #10:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

10

output:

Yes
1 1 1 1 1 1 1 1 1 1 
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 
1 0 1 1 1 1 1 1 1 1 
0 -1 0 -1 -1 -1 -1 -1 -1 -1 
1 0 1 0 1 1 1 1 1 1 
0 -1 0 -1 0 -1 -1 -1 -1 -1 
1 0 1 0 1 0 1 1 1 1 
0 -1 0 -1 0 -1 0 -1 -1 -1 
1 0 1 0 1 0 1 0 1 1 
0 -1 0 -1 0 -1 0 -1 0 -1 

result:

ok OK, Accepted.

Test #11:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

21

output:

No

result:

ok OK, Accepted.

Test #12:

score: 0
Accepted
time: 0ms
memory: 3976kb

input:

37

output:

No

result:

ok OK, Accepted.

Test #13:

score: 0
Accepted
time: 0ms
memory: 3984kb

input:

73

output:

No

result:

ok OK, Accepted.

Test #14:

score: 0
Accepted
time: 1ms
memory: 4276kb

input:

100

output:

Yes
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

ok OK, Accepted.

Test #15:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

233

output:

No

result:

ok OK, Accepted.

Test #16:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

555

output:

No

result:

ok OK, Accepted.

Test #17:

score: 0
Accepted
time: 19ms
memory: 6392kb

input:

666

output:

Yes
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok OK, Accepted.

Test #18:

score: 0
Accepted
time: 34ms
memory: 7600kb

input:

888

output:

Yes
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok OK, Accepted.

Test #19:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

999

output:

No

result:

ok OK, Accepted.

Test #20:

score: 0
Accepted
time: 39ms
memory: 8044kb

input:

1000

output:

Yes
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok OK, Accepted.