QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#650282 | #7858. Basic Equation Solving | Mrlaolu# | WA | 0ms | 3576kb | C++23 | 2.5kb | 2024-10-18 14:26:25 | 2024-10-18 14:26:26 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define l first
#define r second
using namespace std;
using PII = pair<int,int>;
ll ans[4001][4001]={0};
void solve(){
ll n;
cin >> n;
vector<vector<ll>> arr(n+1);
vector<ll> nedc(n+1);
vector<ll> nedl(n+1);
vector<PII> colomn(n+1);
vector<PII> lie(n+1);
for (int i=1;i<=n;i++){
string s;
cin >> s;
ll zheng=0;
ll fu=0;
arr[i].resize(n+1,0);
for (int j=0;j<n;j++)
{
char c;
c=s[j];
if (c=='+') arr[i][j+1]=1,zheng++;
else arr[i][j+1]=-1,fu++;
}
PII a={fu*-1,zheng};
colomn[i]=a;
}
for (int i=1;i<=n;i++) cin >> nedc[i];
for (int i=1;i<=n;i++) cin >> nedl[i];
for (int i=1;i<=n;i++)
{
ll zheng=0;
ll fu=0;
for (int j=1;j<=n;j++)
{
if (arr[j][i]==1) zheng++;
else fu++;
}
PII a={fu*-1,zheng};
lie[i]=a;
}
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
ll f=1;
ll cl=colomn[i].l;
ll cr=colomn[i].r;
ll lil=lie[i].l;
ll lir=lie[i].r;
if (arr[i][j]==-1)
{
cl++;
lil++;
}
else
{
cr--;
lir--;
}
if (nedc[i]<cl || nedc[i]>cr || nedl[j]<lil || nedl[j]>lir) f=0;
if (f)
{
ans[i][j]=0;
colomn[i].l=cl;
colomn[i].r=cr;
lie[i].l=lil;
lie[i].r=lir;
}
else
{
ans[i][j]=1;
}
}
}
ll f=1;
for (int i=1;i<=n;i++)
{
ll c=colomn[i].l+colomn[i].r;
ll li=lie[i].l+lie[i].r;
if (c!=nedc[i] || li!=nedl[i]){
f=0;
break;
}
}
if (f)
{
cout << "Yes\n";
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
cout << ans[i][j];
}
cout << endl;
}
}
else
{
cout << "No\n";
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _ = 1;
while(_--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
1 P=NP
output:
Yes 0
result:
wrong answer 1st lines differ - expected: '766136394', found: 'Yes'