QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756622 | #7857. (-1,1)-Sumplete | asaltfish | WA | 1ms | 5796kb | C++20 | 1.7kb | 2024-11-16 21:13:50 | 2024-11-16 21:13:52 |
Judging History
answer
#include <iostream>
#include <string.h>
#include<queue>
#include<algorithm>
using namespace std;
#define ll long long
#define endl '\n'
int mp[4005][4005], n, row[4005], ans[4005][4005], now[4005], now_cl[4005], cl[4005], ac_row[4005], ac_cl[4005];
int cp[4005];
bool cmp(int x, int y)
{
return cl[x] - now_cl[x] > cl[y] - now_cl[y];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
char p;
cin >> p;
if (p == '+')
mp[i][j] = 1;
else
mp[i][j] = -1, ans[i][j] = 1, now[i]--, now_cl[j]--;
}
}
for (int i = 1; i <= n; i++)
{
cin >> row[i];
cp[i] = i;
}
for (int i = 1; i <= n; i++)
{
cin >> cl[i];
}
for (int i = 1; i <= n; i++)
{
sort(cp + 1, cp + n + 1, cmp);
for (int j = 1; j <= min(n, row[i] - now[i]); j++)
{
ans[i][cp[j]] = 1 - ans[i][cp[j]];
now_cl[cp[j]]++;
}
}
for(int i=1;i<=n;i++)
for (int j = 1; j <= n; j++)
{
if (ans[i][j])
ac_row[i] += mp[i][j], ac_cl[j] += mp[i][j];
}
for (int i = 1; i <= n; i++)
{
if (ac_row[i] != row[i] || ac_cl[i] != cl[i])
{
cout << "N0";
return 0;
}
}
cout << "Yes" << endl;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
cout << ans[i][j];
cout << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5736kb
input:
3 +-+ -++ +-+ 1 1 1 1 -1 3
output:
Yes 111 001 001
result:
ok n=3
Test #2:
score: 0
Accepted
time: 1ms
memory: 5720kb
input:
3 --- -++ +++ -2 -1 0 -2 -1 0
output:
Yes 110 100 000
result:
ok n=3
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5796kb
input:
3 +-+ -++ ++- 1 0 2 2 2 -1
output:
N0
result:
wrong answer invalid output