QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#727197 | #3322. Array of Discord | gambit# | AC ✓ | 1ms | 3828kb | C++17 | 1.2kb | 2024-11-09 11:56:39 | 2024-11-09 11:56:39 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;cin>>n;
vector<string> v(n);
for(int i=0;i<n;i++) cin>>v[i];
for(int i=0;i<n;i++) {
if(i+1<n && v[i].length() == v[i+1].length()) {
for(int j=0;j<v[i].length();j++) {
char tmp = v[i][j];
v[i][j]='9';
if(stoll(v[i]) > stoll(v[i+1])) {
for(int k=0;k<n;k++) cout << v[k] << ' ';
return 0;
}
v[i][j]=tmp;
}
}
if(i-1>=0 && v[i].length() == v[i-1].length()) {
for(int j=0;j<v[i].length();j++) {
char tmp = v[i][j];
if(v[i].length()==1) v[i][j]='0';
else v[i][j]='1';
if(stoll(v[i-1]) > stoll(v[i])) {
for(int k=0;k<n;k++) cout << v[k] << ' ';
return 0;
}
v[i][j]=tmp;
}
}
}
cout << "impossible";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
10 0 1 2 3 4 5 6 7 8 9
output:
9 1 2 3 4 5 6 7 8 9
result:
ok single line: '9 1 2 3 4 5 6 7 8 9 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 0 0
output:
9 0
result:
ok single line: '9 0 '
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 0 1
output:
9 1
result:
ok single line: '9 1 '
Test #4:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
2 0 9
output:
impossible
result:
ok single line: 'impossible'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2 1 9
output:
1 0
result:
ok single line: '1 0 '
Test #6:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
2 9 9
output:
9 0
result:
ok single line: '9 0 '
Test #7:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
3 0 0 9
output:
9 0 9
result:
ok single line: '9 0 9 '
Test #8:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
3 0 1 9
output:
9 1 9
result:
ok single line: '9 1 9 '
Test #9:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
3 0 9 9
output:
0 9 0
result:
ok single line: '0 9 0 '
Test #10:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
3 1 1 9
output:
9 1 9
result:
ok single line: '9 1 9 '
Test #11:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 1 9 9
output:
1 0 9
result:
ok single line: '1 0 9 '
Test #12:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
16 2 71 715 8644 26715 307502 2324439 30264664 760621241 2171917204 57818327666 292516777442 3651910783870 48842229555299 853890859452968 1000000000000000
output:
impossible
result:
ok single line: 'impossible'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
100 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9
output:
9 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9
result:
ok single line: '9 0 0 0 0 0 0 0 0 1 1 1 1 1 1 ... 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 '
Test #14:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
100 103686177641199 104444982894378 127365272122090 128565790046386 130037229603796 134296302387420 139217941581739 146876684863422 178081304294766 178196158523922 196438902405679 198472691217092 200741037217544 203832700490868 213072248638449 215446400565612 216420336595460 223289609205205 22344543...
output:
903686177641199 104444982894378 127365272122090 128565790046386 130037229603796 134296302387420 139217941581739 146876684863422 178081304294766 178196158523922 196438902405679 198472691217092 200741037217544 203832700490868 213072248638449 215446400565612 216420336595460 223289609205205 223445430757...
result:
ok single line: '903686177641199 10444498289437...96526810146276 999664819987727 '
Test #15:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
31 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
impossible
result:
ok single line: 'impossible'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
31 1 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
1 0 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
result:
ok single line: '1 0 10 99 100 999 1000 9999 10...9999999999999 1000000000000000 '
Test #17:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
32 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 19999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
result:
ok single line: '0 9 10 99 100 999 1000 9999 10...9999999999999 1000000000000000 '
Test #18:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
32 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 1999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
result:
ok single line: '0 9 10 99 100 999 1000 9999 10...9999999999999 1000000000000000 '
Test #19:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
32 0 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
9 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
result:
ok single line: '9 0 9 10 99 100 999 1000 9999 ...9999999999999 1000000000000000 '
Test #20:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
32 0 9 10 99 100 999 1000 9999 10000 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
output:
0 9 10 99 100 999 1000 9999 90000 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000
result:
ok single line: '0 9 10 99 100 999 1000 9999 90...9999999999999 1000000000000000 '
Test #21:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
32 0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 1000000000000000 1000000000...
output:
0 9 10 99 100 999 1000 9999 10000 99999 100000 999999 1000000 9999999 10000000 99999999 100000000 999999999 1000000000 9999999999 10000000000 99999999999 100000000000 999999999999 1000000000000 9999999999999 10000000000000 99999999999999 100000000000000 999999999999999 9000000000000000 1000000000000...
result:
ok single line: '0 9 10 99 100 999 1000 9999 10...0000000000000 1000000000000000 '
Test #22:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
100 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:
9 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 single line: '9 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 '
Test #23:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
100 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 99999999...
output:
999999999999999 199999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999999 999999999999...
result:
ok single line: '999999999999999 19999999999999...99999999999999 999999999999999 '
Test #24:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
100 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000...
output:
9000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 1000000000000000 10000000000...
result:
ok single line: '9000000000000000 1000000000000...0000000000000 1000000000000000 '
Test #25:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 331952469247314 937255643249971
output:
331952469247314 137255643249971
result:
ok single line: '331952469247314 137255643249971 '
Test #26:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
3 247301607981210 850089244189921 853528852574406
output:
947301607981210 850089244189921 853528852574406
result:
ok single line: '947301607981210 850089244189921 853528852574406 '
Test #27:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
4 416144834135327 484047564932579 761840990192685 993244542449640
output:
916144834135327 484047564932579 761840990192685 993244542449640
result:
ok single line: '916144834135327 484047564932579 761840990192685 993244542449640 '
Test #28:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
5 193905798839532 261453309320443 461073544459089 536688219481425 902048341617237
output:
993905798839532 261453309320443 461073544459089 536688219481425 902048341617237
result:
ok single line: '993905798839532 26145330932044...36688219481425 902048341617237 '
Test #29:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
5 3419312 10287868 17871635 57293660 82123335
output:
3419312 90287868 17871635 57293660 82123335
result:
ok single line: '3419312 90287868 17871635 57293660 82123335 '
Test #30:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
7 21430060800872 42844040717697 49693369550951 52138792523072 64903906506310 74534679140555 83452234460131
output:
91430060800872 42844040717697 49693369550951 52138792523072 64903906506310 74534679140555 83452234460131
result:
ok single line: '91430060800872 42844040717697 ... 74534679140555 83452234460131 '
Test #31:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
10 535827333628 1434129722279 1537437189396 2436676719511 2574103938469 4864813538008 5006837504205 6080449379529 8397355274813 9258541148218
output:
535827333628 9434129722279 1537437189396 2436676719511 2574103938469 4864813538008 5006837504205 6080449379529 8397355274813 9258541148218
result:
ok single line: '535827333628 9434129722279 153...29 8397355274813 9258541148218 '
Test #32:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
6 508267 2204434 3399258 4271875 7006005 7597702
output:
508267 9204434 3399258 4271875 7006005 7597702
result:
ok single line: '508267 9204434 3399258 4271875 7006005 7597702 '
Test #33:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
10 133528524089 257197832419 590709664623 667185860007 681355225631 720837602220 816988753920 831295237940 914162376139 931864838800
output:
933528524089 257197832419 590709664623 667185860007 681355225631 720837602220 816988753920 831295237940 914162376139 931864838800
result:
ok single line: '933528524089 257197832419 5907...7940 914162376139 931864838800 '
Test #34:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
8 381105331 499264582 511555933 610056473 641698779 775029215 814719279 876334632
output:
981105331 499264582 511555933 610056473 641698779 775029215 814719279 876334632
result:
ok single line: '981105331 499264582 511555933 ... 775029215 814719279 876334632 '
Test #35:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
58 15677013695215 49282305356609 54033080851098 66914845664546 77725378913770 79923117536463 89108621698836 112874155164315 128594778149587 145797487589580 155030407841019 159104697343941 174235001888341 203841087437740 207743126388290 212385291705953 215490937257012 231425325851602 294599570418041 ...
output:
95677013695215 49282305356609 54033080851098 66914845664546 77725378913770 79923117536463 89108621698836 112874155164315 128594778149587 145797487589580 155030407841019 159104697343941 174235001888341 203841087437740 207743126388290 212385291705953 215490937257012 231425325851602 294599570418041 299...
result:
ok single line: '95677013695215 49282305356609 ...74345206292635 986163457580524 '
Test #36:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
26 2033559326066 96968090827264 103206854261726 104339592500832 160681292765105 219636221412971 233345139608899 254394591968963 280178165012704 281568309709533 305396334083226 331686517902966 363544085062268 420100108808440 441516157975572 553979720307085 575508017428717 578952183688573 651994087431...
output:
2033559326066 96968090827264 903206854261726 104339592500832 160681292765105 219636221412971 233345139608899 254394591968963 280178165012704 281568309709533 305396334083226 331686517902966 363544085062268 420100108808440 441516157975572 553979720307085 575508017428717 578952183688573 651994087431399...
result:
ok single line: '2033559326066 96968090827264 9...06749369821889 965227214638645 '
Test #37:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
89 1215976715704 19272218323394 20387853667930 39005123354959 42622884920225 56951436331605 59913662902435 86043883057856 88245091560147 101128621171273 106940896421387 113676041568625 132133318972042 139219423429538 151029202554918 159833479224190 188425168595343 239603793051490 241200439424237 243...
output:
1215976715704 99272218323394 20387853667930 39005123354959 42622884920225 56951436331605 59913662902435 86043883057856 88245091560147 101128621171273 106940896421387 113676041568625 132133318972042 139219423429538 151029202554918 159833479224190 188425168595343 239603793051490 241200439424237 243806...
result:
ok single line: '1215976715704 99272218323394 2...59069002072057 969148557555757 '
Test #38:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
43 17250300776984 27452441914610 35785134244903 56584073096673 65748985019976 116435699646103 139862662845855 142697762311433 147645780110362 175366780777827 179533453226155 202143723346718 240444992329395 248593032866027 294822098082932 465450133981044 467639608536991 494007892921191 49942434970993...
output:
97250300776984 27452441914610 35785134244903 56584073096673 65748985019976 116435699646103 139862662845855 142697762311433 147645780110362 175366780777827 179533453226155 202143723346718 240444992329395 248593032866027 294822098082932 465450133981044 467639608536991 494007892921191 499424349709939 5...
result:
ok single line: '97250300776984 27452441914610 ...63667662057758 995668346646669 '