QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729311#7857. (-1,1)-SumpleteAshbourneWA 1ms7764kbC++231.3kb2024-11-09 16:52:112024-11-09 16:52:12

Judging History

This is the latest submission verdict.

  • [2024-11-09 16:52:12]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7764kb
  • [2024-11-09 16:52:11]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 4e3 + 10;
int a[N][N], tp[N][N], mp[N][N];
int main(){
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n;
	vector<int> a(n + 1), b(n + 1), c(n + 1), d(n + 1);
	for(int i = 1; i <= n; ++ i)
		for(int j = 1; j <= n; ++ j){
			char ch; cin >> ch;
			if(ch == '+') tp[i][j] = 1;
			else tp[i][j] = 0, a[i] ++, b[j] ++ ;
		}
	int pd1 = 0, pd2 = 0;
	for(int i = 1; i <= n; ++ i){
		int x; cin >> x; a[i] += x;
		c[i] = a[i]; pd1 += a[i];
	}
	for(int i = 1; i <= n; ++ i){
		int x; cin >> x; b[i] += x;
	    pd2 += b[i];
	}
	if(pd1 != pd2){
		cout << "No" << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= a[i]; ++ j)mp[i][j] = 1, d[j]++;
	}
	for(int j = 1; j <= n; ++ j){
		int tot = d[j] - b[j];
		// cout << tot << endl;
		if(tot < 0){
			cout << "No" << endl;
			return 0;
		}
		for(int i = 1; i <= n; ++ i){
			if(!mp[i][j])continue;
			if(tot > 0 && c[i] != n){
				c[i]++; swap(mp[i][j], mp[i][c[i]]);
				d[c[i]]++;
				--tot;
				continue;
			}
		}
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= n; ++ i){
		for(int j = 1; j <= n; ++ j){
			if(tp[i][j]){
				cout << (mp[i][j]? 1 : 0); 
			}else cout << (mp[i][j]? 0 : 1);
		}
		cout << endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
001
001
111

result:

ok n=3

Test #2:

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

input:

3
---
-++
+++
-2 -1 0
-2 -1 0

output:

Yes
110
100
000

result:

ok n=3

Test #3:

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

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

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

input:

20
+-------+-----+++-++
-+-++++----++-++-++-
-+++--+---+--+-++---
-+++-+--+----++---+-
+++-+-++++++-+-+---+
-++-----+----++++++-
+-++--+++++-++-+----
+-+----+---+-+++--+-
+++++-+++++----+--+-
------++++---+--++--
++++--------++++--+-
-+-+-++++-+-++-++--+
---+-++---+-++-++---
+-++++-++----+-+++--
+-+...

output:

No

result:

wrong answer Jury has the answer but participant has not