QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#469422 | #8892. Power Grid | Lynkcat# | 5 | 476ms | 27312kb | C++20 | 2.0kb | 2024-07-09 19:05:09 | 2024-07-09 19:05:10 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N
using namespace std;
const int N=1005;
int n,m;
int ans[N][N],b[N],a[N];
int c[N][N];
map<int,int>f[N];
void dfs(int k,int sm)
{
if (f[k].count(sm)) return;
if (k==n)
{
if (sm!=0&&(n==m||sm%(n-m)!=0)) return;
int o=0;
if (sm!=0) o=sm/(n-m);
for (int i=0;i<m;i++) a[i]-=o;
for (int i=0;i<n;i++) b[i]-=o;
for (int i=1;i<m;i++) ans[0][i]=a[i],b[0]-=a[i];
for (int i=0;i<n;i++)
{
ans[i][0]=b[i];
}
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++) cout<<ans[i][j]<<" ";
cout<<'\n';
}
fflush(stdout);
exit(0);
}
for (int i=-m;i<=m;i++)
{
b[k]=i;
bool bl=1;
for (int j=0;j<m;j++)
{
if (abs(b[k]-a[j])!=c[k][j])
{
bl=0;
break;
}
}
if (bl) dfs(k+1,sm+i);
}
f[k][sm]=1;
}
void BellaKira()
{
cin>>n>>m;
for (int i=0;i<n;i++)
for (int j=0;j<m;j++)
cin>>c[i][j];
int z1=0;
for (int i=0;i<m;i++)z1+=(c[0][i]==1);
for (int x=0;x<=z1;x++)
{
poly g;
int nx=x;
for (int i=0;i<m;i++)
{
if (c[0][i]==0) a[i]=0;
else
{
if (!nx) a[i]=-1;
else a[i]=1,nx--;
}
}
int sm=0;
for (int i=0;i<m;i++) sm-=a[i];
dfs(1,sm);
for (int i=1;i<n;i++) f[i].clear();
}
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 1ms
memory: 5748kb
input:
1 1 0
output:
0
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 5748kb
input:
1 1 0
output:
0
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 5772kb
input:
1 2 1 1
output:
1 1
result:
ok correct
Test #4:
score: -8
Wrong Answer
time: 1ms
memory: 5768kb
input:
3 1 0 3 1
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #23:
score: 11
Accepted
time: 1ms
memory: 5684kb
input:
1 1 0
output:
0
result:
ok correct
Test #24:
score: -11
Wrong Answer
time: 1ms
memory: 5740kb
input:
1 10 230 289 918 752 224 184 573 217 398 715
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #4:
score: 0
Wrong Answer
Test #30:
score: 6
Accepted
time: 1ms
memory: 5808kb
input:
2 2 0 0 0 0
output:
0 0 0 0
result:
ok correct
Test #31:
score: -6
Wrong Answer
time: 1ms
memory: 5684kb
input:
2 2 7 7 7 7
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #5:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 1ms
memory: 5628kb
input:
2 4 253 431 207 483 243 65 289 13
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #6:
score: 5
Accepted
Test #58:
score: 5
Accepted
time: 67ms
memory: 19156kb
input:
1000 1000 1 0 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 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 1 0 1 1 0...
output:
-380 1 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 1 0 0 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 1 1 1...
result:
ok correct
Test #62:
score: 0
Accepted
time: 61ms
memory: 19532kb
input:
1000 871 0 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 1 1 0 0 0 0...
output:
491 -1 -1 -1 -1 -1 0 0 0 -1 0 -1 0 0 -1 0 0 -1 0 -1 -1 -1 -1 0 0 0 -1 -1 0 -1 -1 0 0 0 0 0 -1 -1 -1 -1 0 -1 -1 0 0 -1 0 0 0 0 0 -1 -1 0 -1 0 0 0 -1 -1 -1 0 0 -1 -1 0 0 0 -1 0 -1 0 -1 -1 -1 -1 0 -1 -1 0 0 0 -1 0 -1 0 -1 -1 -1 -1 -1 0 -1 -1 0 -1 -1 -1 0 0 -1 -1 -1 -1 0 0 -1 -1 -1 -1 0 -1 -1 0 -1 -1 0 ...
result:
ok correct
Test #63:
score: 0
Accepted
time: 82ms
memory: 18824kb
input:
1000 1000 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok correct
Test #65:
score: 0
Accepted
time: 1ms
memory: 5808kb
input:
1 1 0
output:
0
result:
ok correct
Test #66:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
1 6 1 1 1 0 1 1
output:
0 0 0 1 0 0
result:
ok correct
Test #67:
score: 0
Accepted
time: 73ms
memory: 19428kb
input:
999 888 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
-6201 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
result:
ok correct
Subtask #7:
score: 0
Wrong Answer
Test #68:
score: 0
Wrong Answer
time: 0ms
memory: 5688kb
input:
2 2 5 52 52 5
output:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #8:
score: 0
Skipped
Dependency #2:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
0%