QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#469419 | #8892. Power Grid | Lynkcat# | 0 | 253ms | 27208kb | C++20 | 1.8kb | 2024-07-09 19:01:01 | 2024-07-09 19:01:01 |
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=-3;i<=3;i++)
{
b[k]=i*c[0][0];
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];
for (int s=0;s<=m;s++)
{
poly g;
for (int i=0;i<m;i++)
if (i<s) a[i]=c[0][i];
else a[i]=-c[0][i];
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();
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 1ms
memory: 5820kb
input:
1 1 0
output:
0
result:
ok correct
Test #2:
score: 0
Accepted
time: 1ms
memory: 7820kb
input:
1 1 0
output:
0
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 5764kb
input:
1 2 1 1
output:
1 1
result:
ok correct
Test #4:
score: -8
Wrong Answer
time: 1ms
memory: 5688kb
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: 5816kb
input:
1 1 0
output:
0
result:
ok correct
Test #24:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
1 10 230 289 918 752 224 184 573 217 398 715
output:
270 211 -418 -252 276 316 -73 283 102 -215
result:
ok correct
Test #25:
score: 0
Accepted
time: 1ms
memory: 5740kb
input:
1 1000 298 440 513 326 225 36 897 92 347 346 919 370 28 957 593 332 736 960 346 969 329 893 380 523 104 345 860 451 290 958 164 386 508 786 605 778 453 500 376 670 86 283 844 408 282 541 479 827 9 558 473 251 184 694 920 905 1000 515 846 506 741 403 552 869 37 667 377 350 711 304 509 471 164 901 487...
output:
202 60 -13 174 275 464 -397 408 153 154 -419 130 472 -457 -93 168 -236 -460 154 -469 171 -393 120 -23 396 155 -360 49 210 -458 336 114 -8 -286 -105 -278 47 0 124 -170 414 217 -344 92 218 -41 21 -327 491 -58 27 249 316 -194 -420 -405 -500 -15 -346 -6 -241 97 -52 -369 463 -167 123 150 -211 196 -9 29 3...
result:
ok correct
Test #26:
score: 0
Accepted
time: 1ms
memory: 5708kb
input:
1 1000 684 573 532 550 99 296 284 671 559 397 215 977 399 460 710 152 111 966 525 184 613 982 274 805 541 238 258 357 884 969 343 700 55 610 351 470 212 842 908 911 752 593 257 396 343 937 253 395 452 718 513 754 990 149 853 895 783 329 20 728 119 602 15 202 475 49 578 427 27 349 547 225 223 209 197...
output:
-184 -73 -32 -50 401 204 216 -171 -59 103 285 -477 101 40 -210 348 389 -466 -25 316 -113 -482 226 -305 -41 262 242 143 -384 -469 157 -200 445 -110 149 30 288 -342 -408 -411 -252 -93 243 104 157 -437 247 105 48 -218 -13 -254 -490 351 -353 -395 -283 171 480 -228 381 -102 485 298 25 451 -78 73 473 151 ...
result:
ok correct
Test #27:
score: 0
Accepted
time: 0ms
memory: 5828kb
input:
1 1000 379 888 365 408 845 405 394 954 362 367 421 913 426 418 401 422 389 890 393 898 924 405 916 408 378 419 393 372 398 863 363 903 408 872 403 372 368 383 400 401 849 878 386 923 863 410 884 387 905 388 929 390 338 416 385 388 420 371 930 411 391 923 389 952 388 385 387 936 931 384 867 889 390 8...
output:
-87 422 -101 -58 379 -61 -72 488 -104 -99 -45 447 -40 -48 -65 -44 -77 424 -73 432 458 -61 450 -58 -88 -47 -73 -94 -68 397 -103 437 -58 406 -63 -94 -98 -83 -66 -65 383 412 -80 457 397 -56 418 -79 439 -78 463 -76 -128 -50 -81 -78 -46 -95 464 -55 -75 457 -77 486 -78 -81 -79 470 465 -82 401 423 -76 398 ...
result:
ok correct
Test #28:
score: 0
Accepted
time: 1ms
memory: 5816kb
input:
1 1000 1 0 0 3 1 0 0 0 0 0 0 2 1 1 0 0 1 0 1 0 0 0 2 3 0 0 2 0 3 2 2 1 1 0 2 0 1 2 1 0 0 1 0 1 0 0 1 1 2 2 1 0 0 0 1 3 2 3 1 1 0 1 2 1 1 0 2 1 1 2 1 2 1 4 1 2 0 2 2 1 0 1 2 4 1 0 1 1 2 0 4 1 1 0 0 0 0 1 1 0 0 1 0 0 2 1 1 2 1 0 4 1 2 2 0 1 0 0 0 1 2 3 0 0 1 2 0 2 2 0 1 2 0 2 1 1 2 0 2 0 0 0 0 1 0 1 1...
output:
0 -1 -1 2 0 -1 -1 -1 -1 -1 -1 1 0 0 -1 -1 0 -1 0 -1 -1 -1 1 2 -1 -1 1 -1 2 1 1 0 0 -1 1 -1 0 1 0 -1 -1 0 -1 0 -1 -1 0 0 1 1 0 -1 -1 -1 0 2 1 2 0 0 -1 0 1 0 0 -1 1 0 0 1 0 1 0 3 0 1 -1 1 1 0 -1 0 1 3 0 -1 0 0 1 -1 3 0 0 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 1 0 0 1 0 -1 3 0 1 1 -1 0 -1 -1 -1 0 1 2 -1 -1 0 1 ...
result:
ok correct
Test #29:
score: -11
Wrong Answer
time: 1ms
memory: 5748kb
input:
1 766 1 0 1 0 1 2 0 3 0 0 1 2 0 1 0 2 0 1 1 4 1 3 0 0 2 2 2 2 1 1 1 2 1 2 0 1 2 1 2 0 4 0 1 0 0 0 0 0 1 2 0 0 1 2 2 4 1 1 1 2 0 1 3 2 1 0 0 0 0 1 0 1 0 1 2 2 3 0 3 1 0 0 1 1 0 1 4 3 1 2 0 3 0 1 1 2 1 2 1 1 2 0 1 0 0 2 1 1 2 0 2 0 0 1 1 3 1 0 1 2 1 0 0 3 2 0 0 2 2 0 0 1 0 1 1 1 2 0 2 3 1 1 1 3 0 0 2 ...
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: 5692kb
input:
2 2 0 0 0 0
output:
0 0 0 0
result:
ok correct
Test #31:
score: 0
Accepted
time: 1ms
memory: 5744kb
input:
2 2 7 7 7 7
output:
7 -7 0 0
result:
ok correct
Test #32:
score: -6
Wrong Answer
time: 0ms
memory: 5756kb
input:
2 4 7 7 7 7 7 7 7 7
output:
-5 6 6 6 -1 0 0 0
result:
wrong answer Rowsum 1 and columnsum 1 did not correspond to C
Subtask #5:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 1ms
memory: 5744kb
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: 0
Wrong Answer
Test #58:
score: 5
Accepted
time: 65ms
memory: 19032kb
input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 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 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: -5
Wrong Answer
time: 27ms
memory: 12444kb
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:
result:
wrong output format Unexpected end of file - int32 expected
Subtask #7:
score: 0
Wrong Answer
Test #68:
score: 0
Wrong Answer
time: 1ms
memory: 5804kb
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%