QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#473772 | #5544. Grid Game | yzkkai# | AC ✓ | 16ms | 4260kb | C++20 | 899b | 2024-07-12 13:59:53 | 2024-07-12 13:59:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
inline void solve() {
int n, m;
cin >> n >> m;
vector g(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> g[i][j];
}
}
auto check = [&] (int x, int y) -> bool {
return (x >= n || y >= m || g[x][y] == -1);
};
LL res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (g[i][j] == -1) continue;
if (check(i + 1, j) && check(i, j + 1)) {
res ^= g[i][j];
}
}
}
if (res) {
cout << "first\n";
} else {
cout << "second\n";
}
return;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
5 6 0 0 0 0 0 0 0 3 3 0 0 0 0 0 3 -1 0 0 0 0 3 3 3 3 0 0 -1 -1 -1 -1
output:
first
result:
ok single line: 'first'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
2 2 1 1 2 -1
output:
first
result:
ok single line: 'first'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1 1 -1
output:
second
result:
ok single line: 'second'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
1 1 0
output:
second
result:
ok single line: 'second'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1 500 612866757 -1 170099640 81369597 686362045 -1 881896501 976801805 719620154 608593304 966389969 328378946 507635545 802692138 300403679 836364030 549500574 415279944 930818720 415608262 520761434 936617110 -1 -1 267207033 722184019 877398796 32901337 371918751 425945951 1383354 93894469 2476850...
output:
second
result:
ok single line: 'second'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
500 1 771241187 104736110 278328807 116558615 139133289 357639029 701440755 -1 4654833 624497474 35581801 664197106 388169084 401688188 555679040 85794603 356439891 62688862 631718530 278116515 462582738 169312687 646329181 965094975 609536716 151230228 200950555 805462441 337840870 586107944 303252...
output:
first
result:
ok single line: 'first'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
500 1 608401636 206451411 797526361 175803019 808049341 570039035 927020568 551777775 115561309 217278975 9358574 742898292 898154820 196000754 925847073 240623844 166741583 45677084 172696682 848859786 481553360 168976055 109683059 396884179 321697622 453198230 324998933 24548119 426527531 38833316...
output:
second
result:
ok single line: 'second'
Test #8:
score: 0
Accepted
time: 9ms
memory: 4180kb
input:
500 500 -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:
second
result:
ok single line: 'second'
Test #9:
score: 0
Accepted
time: 7ms
memory: 4260kb
input:
500 500 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 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 ...
output:
second
result:
ok single line: 'second'
Test #10:
score: 0
Accepted
time: 16ms
memory: 4100kb
input:
500 500 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...
output:
first
result:
ok single line: 'first'
Test #11:
score: 0
Accepted
time: 9ms
memory: 4104kb
input:
500 500 -1 -1 -1 53078603 922944834 -1 -1 947499554 912659633 -1 461099769 -1 982836037 -1 -1 -1 246843767 -1 -1 -1 467695369 -1 836844027 440788154 536573603 185574246 974342651 -1 -1 492566038 816893345 -1 -1 689462290 -1 -1 949945909 51074670 -1 -1 -1 62944569 74181192 -1 -1 741146127 -1 -1 44214...
output:
first
result:
ok single line: 'first'
Test #12:
score: 0
Accepted
time: 15ms
memory: 4112kb
input:
500 500 276054934 284197147 80989118 465195817 -1 595966971 314495545 -1 -1 278015503 985865309 698930194 -1 593436762 746187609 -1 -1 858139440 -1 -1 449059667 761937956 12374159 183267535 -1 -1 120044963 -1 -1 -1 -1 540474338 -1 423521136 -1 -1 383199846 997776893 76418070 -1 -1 -1 157800626 85541...
output:
second
result:
ok single line: 'second'
Test #13:
score: 0
Accepted
time: 7ms
memory: 4148kb
input:
500 500 -1 8594542 26012990 623768845 708708519 999022297 -1 185179394 926224752 505077071 983960803 79376034 17828212 165705700 370420071 945986520 384167223 -1 271202868 908691208 465929026 511065691 685770121 442391652 675350979 881313572 451172142 482553786 12124949 101919207 94690743 738237065 ...
output:
first
result:
ok single line: 'first'
Test #14:
score: 0
Accepted
time: 15ms
memory: 4244kb
input:
500 500 480326386 544770957 496941505 337710099 579894396 13996995 365184764 844443267 858558422 785550347 130125108 436849551 91508896 849730945 574510186 845984407 388300233 137430427 484815360 823959280 239725597 437674346 826420605 207365363 745685437 351211182 371165178 903357890 954576024 6804...
output:
second
result:
ok single line: 'second'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1 1
output:
first
result:
ok single line: 'first'
Test #16:
score: 0
Accepted
time: 11ms
memory: 4108kb
input:
500 500 -1 -1 -1 -1 -1 -1 951693355 560646438 -1 -1 -1 -1 -1 -1 681466622 -1 -1 -1 -1 -1 -1 18532681 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 827009760 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 211801671 -1 -1 -1 -1 176815535 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 16105103 -1 -1 -1 -1 173172704 -1 -1 -1 -1 389528...
output:
first
result:
ok single line: 'first'
Test #17:
score: 0
Accepted
time: 10ms
memory: 4260kb
input:
500 500 -1 24222064 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 914478308 541390995 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 867259320 787501693 -1 371846885 -1 -1 -1 893151509 -1 736679464 -1 -1 -1 -1 -1 -1 562194985 -1 -1 437269526 361304362 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 596669869 -1 -1 67547229 12...
output:
second
result:
ok single line: 'second'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
390 84 -1 365338934 -1 -1 126117654 -1 -1 -1 546787684 602962033 -1 -1 -1 -1 697509700 707586965 325159734 100394441 -1 571489064 59203516 994839108 132020350 -1 283799586 -1 917142960 -1 -1 186367446 263448187 -1 883768045 -1 446865118 -1 -1 -1 -1 848362172 -1 962769416 -1 -1 383215275 704942740 -1...
output:
first
result:
ok single line: 'first'
Test #19:
score: 0
Accepted
time: 9ms
memory: 3720kb
input:
375 386 -1 630909047 568594047 160446953 -1 799149110 643477550 803849181 -1 498192763 387537156 995585356 -1 510305850 512633515 -1 936601700 -1 -1 491940400 22628115 420432569 -1 -1 334406884 68440679 75961030 422167579 581688801 -1 -1 -1 -1 -1 595096207 -1 -1 -1 -1 131799365 -1 753659570 42907418...
output:
first
result:
ok single line: 'first'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
162 101 -1 -1 -1 28342311 347980427 877193605 -1 -1 146488348 925037987 927492260 -1 -1 -1 -1 332959790 741844019 -1 443495846 -1 -1 432254807 701416816 -1 862287449 451630351 -1 195484763 233111327 -1 -1 631733301 959216151 -1 564766211 365337710 171712376 -1 -1 -1 -1 -1 -1 270176483 -1 -1 -1 81684...
output:
second
result:
ok single line: 'second'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3648kb
input:
268 161 -1 625169773 -1 392193456 930205706 -1 -1 -1 893215868 -1 -1 343357284 467986534 120380596 35194749 -1 741771191 984198837 -1 -1 -1 473027685 -1 -1 -1 -1 -1 256749824 -1 484941135 498996517 -1 863649188 -1 -1 -1 509782196 -1 -1 726906749 -1 -1 -1 -1 -1 -1 754451217 -1 895425615 -1 572756277 ...
output:
second
result:
ok single line: 'second'
Test #22:
score: 0
Accepted
time: 9ms
memory: 4112kb
input:
500 500 876388814 -1 836898941 -1 798202886 -1 210292330 -1 873162034 -1 277575994 -1 542455591 -1 909262220 -1 410889402 -1 637038528 -1 882899353 -1 357268340 -1 391476296 -1 44731352 -1 960348868 -1 108662247 -1 67548864 -1 337522085 -1 374281291 -1 943809736 -1 755251167 -1 917217162 -1 87330361...
output:
first
result:
ok single line: 'first'
Test #23:
score: 0
Accepted
time: 12ms
memory: 4108kb
input:
500 500 149301804 -1 270883001 -1 608478409 -1 579595957 -1 451400363 -1 497140392 -1 295590696 -1 820329792 -1 923497635 -1 252344338 -1 440531938 -1 346617976 -1 915121310 -1 521398031 -1 824586808 -1 441252477 -1 204821225 -1 772170055 -1 932477996 -1 378571009 -1 50281564 -1 190080793 -1 5250579...
output:
second
result:
ok single line: 'second'
Test #24:
score: 0
Accepted
time: 12ms
memory: 4184kb
input:
500 500 378088450 146891877 188465789 989581139 999814435 652039926 85568163 868309223 874189510 96175304 872740603 386860145 654512431 728188349 116889527 866066911 762374231 635403977 87703283 543988706 908416639 916625517 890007232 270803133 667640420 270072182 690337882 696513530 719192356 71105...
output:
first
result:
ok single line: 'first'
Test #25:
score: 0
Accepted
time: 12ms
memory: 4120kb
input:
500 500 154000917 615444183 869861716 345388359 875484220 581340866 256760765 106882920 677281158 815247186 400731425 290521031 904261995 219676581 943991828 917068834 281119831 709957984 895136874 249189957 354850984 753447280 545999572 844450531 754344304 990184382 184039023 488287261 122934635 47...
output:
second
result:
ok single line: 'second'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 1 1000000000
output:
first
result:
ok single line: 'first'
Test #27:
score: 0
Accepted
time: 8ms
memory: 4148kb
input:
500 500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 824695473 -1 0 0 0...
output:
first
result:
ok single line: 'first'
Test #28:
score: 0
Accepted
time: 11ms
memory: 4144kb
input:
500 500 449575741 125075601 730341911 875055834 -1 -1 356045427 719649942 45090079 114342356 132415412 915946017 939993462 71867978 985562209 330579434 403572037 385703082 556612788 579425196 750207074 328958233 570497278 80104866 233728880 169932402 743763181 384343550 726537724 14744677 92615162 7...
output:
second
result:
ok single line: 'second'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 2 2022 0
output:
second
result:
ok single line: 'second'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
2 1 2022 0
output:
second
result:
ok single line: 'second'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
2 2 -1 69 420 0
output:
second
result:
ok single line: 'second'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
2 2 1337 -1 -1 1337
output:
second
result:
ok single line: 'second'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
2 2 420 -1 -1 69
output:
first
result:
ok single line: 'first'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 500 355612735 722080661 940431952 30452965 765325253 746994238 748663625 92596158 903719740 217450494 83422434 749254417 731693759 584476072 45614636 961936384 -1 209157028 286915045 240828777 677263307 100293944 63038292 16429631 555649237 9240070 -1 669916542 833038095 984329434 281730104 586410...
output:
first
result:
ok single line: 'first'