QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#336783 | #8278. Secret Poems | ucup-team197# | AC ✓ | 1ms | 3868kb | C++20 | 1.7kb | 2024-02-24 21:22:49 | 2024-02-24 21:22:50 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100 + 3;
int n;
string s[N];
bool valid(int x, int y){
return 0 <= x && x <= n - 1 && 0 <= y && y <= n - 1;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 0; i < n; ++i)
cin >> s[i];
string poem = "";
for(int d = 0; d < 2 * n - 1; ++d){
int x, y;
if(d % 2 == 0){
if(d < n){
x = d, y = 0;
}
else{
x = n - 1;
y = d - (n - 1);
}
for(; valid(x, y); --x, ++y){
poem += s[x][y];
}
}
else{
if(d < n){
x = 0, y = d;
}
else{
x = d - (n - 1);
y = n - 1;
}
for(; valid(x, y); --y, ++x){
poem += s[x][y];
}
}
}
// cout << poem << " poem" << endl;
int cnt = 0;
for(int i = 0; i <= n - i - 1; ++i){
if(i == n - i - 1){
s[i][i] = poem[cnt++];
break;
}
for(int y = i; y <= n - i - 1; ++y)
s[i][y] = poem[cnt++];
for(int x = i + 1; x <= n - i - 1; ++x)
s[x][n - i - 1] = poem[cnt++];
for(int y = n - i - 2; y >= i; --y)
s[n - i - 1][y] = poem[cnt++];
for(int x = n - i - 2; x >= i + 1; --x)
s[x][i] = poem[cnt++];
}
// cout << cnt << " cnt" << endl;
// cout << poem.size() << " poem" << endl;
for(int i = 0; i < n; ++i)
cout << s[i] << "\n";
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
5 THSAD IIVOP SEOOH RGETI YMINK
output:
THISI POEMS DNKIA OIHTV OGYRE
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
2 AB CD
output:
AB DC
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
4 ABCD EFGH IJKL MNOP
output:
ABEI KHLF NPOC MJGD
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
8 ABCEFDWL ABCEFDWL ABCEFDWL ABCEFDWL ABCEFDWL ABCEFDWL ABCEFDWL ABCEFDWL
output:
ABAABCEC WLWDFECB DECEFDBA FFWLLWAA EDDLWLBB CWFDWLCC BLLWDFEE AABCEFDF
result:
ok 8 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
20 ABCDEFGHEFGHEFGHIJKL EFGHIJKLMNOPKLMNKEFW IJKLIAAAAJKLIJKLEEEE EFGHIJKLMNOPKLMNKEFW IJKLIAAAAJKLIJKLEEEE IJKLIAAAAJKLIJKLEEEE JKLIJKLEEEEIJKLIAAAA EFGHIJKLMNOPKLMNKEFW ABCDEFGHEFGHEFGHIJKL EFGHIJKLMNOPKLMNKEFW IJKLIAAAAJKLIJKLEEEE EFGHIJKLMNOPKLMNKEFW IJKLIAAAAJKLIJKLEEEE IJKLIAAAAJKLIJKLEEEE JKL...
output:
ABEIFCDGJEIFKHEFILGJ GJEIFKHEJLAANKPEFKLI DLENELILKNIJKLMJIIOJ IAAKIDGJIJKHEJLAAOJJ KJAPILGNAEEWEEAKNFAK AIMKLMJIIOFMAAKHKMEH ALJJKKPELLLEEEAMPAKI MLOEJEWEEAKHMWNJEKFJ JFHLFLELLIEEJEGKLAIG OAKGAJEKEWEKEFPLLILH HEKJEOAJAJAWKEJKLIGK GKKIAHNFJEFLKEJEEGJA NKLLEKGAEAEINIKMEBII ALKKIKLIEELKFMNHEEJL LIELNK...
result:
ok 20 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
100 XIZRFKBGIFYHQYTINRAKHBPJVQGJIJQXTBLLBVNQQQTSAKPIXTORIREMDTGNDFTOZGUZICOMGINGXDXQXYQEWRN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GZXBABWKOCZAOQBKENWFFRFBXOOCQZAXONHAWHXLJPZDLDBYAFKPZBLXVZQUJWTPNGRCDKYRJRWNIIUECLMBNLSUVIEMGJPGBVG ...
result:
ok 99 lines
Test #8:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
98 AWIITUWKFFFFJJAFYGXBSDMHLXUENBIGWUUXSQMWRIOOFYIECDJVUCRUUFWXDRQMJPUPJVJOIRVCURIVIAJPPWDSCYLZBNSRRL OVLTIENSFNUSITTHGHASWIHFEQSDYSFFSASKUUJZSMKNKGBDXZGTHPVRNQWDGTYNXMDLZICESKPMOCSLSVLELDVKYWOQFPUNRH RZGYHTYLPROGTRHSTZOJKRHQGJOQRHZUCGPJQBRUKHBMPUEIVMILPRUKKYFOUJWUYBCNNVHJHWRKAANOCOABIMZCJLGMFJAJDU ...
output:
AWORVIILZUVZGTTUIYHZXJAAHHEWKNTKQKWGMXZMRKYSFFFLNEWCSKTDNUODOLXPNFFURVHEUDXQMZYPRFQLIKQOOSJJIGTZKN TCGXALVYNTYWRQKMDYFQCWVCLLIWAEHGXAMDVBGDFTTFXODNBYQCTFRTNAENUSLKKIMBHFWVGJJCGPBMPSECFDCIDQFIAASLWT BMNDJLLRQKLQUMWJBZOKXODRSJCXAITJNLGFZJCHJULZQQUFAFUKBAVUPIMFTWLEPAISOLMLDXZLHGFXSALVXGOHZBQSRZRINR KBP...
result:
ok 98 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
96 GTHPKKJKUAIXLVQNDZGHHPPURUOMMYWDZVHHNCPIIDOFYXREYSUKPDHPINGMVXWPOWAAJJKIUKIVCIKDZDHUTZDNETZEZJFU HBORTXEIITFJNMZFIQMNVPRXAEMGGHCFKGEAUELEICWYIFUCMKEJHVURPDMQUOWPRDCHQEAKOUHLCEHJSMMTDGLVJRNXQPTO TLKETIQMYASQZUMUFBUYONKMGEEBMIBKGEGTYVDWTGAFFQAFQJDUKIVDHOSTKCDCKZMGKRMRBFUVFMREQWBFLVHQLUFLMTYV GHQSRN...
output:
GTHTBHPOLGXHKRKKTEQKNKOZSTXJKEIRQLSIYWKJWNQIUAIMBRMHDWBPABSPOQFYTIXFAFTUFYNEWMTQGPOSXOLPSJLVNQWL MEGBWAZQHNVNOTUJCDSRXCPHGPWNYKZDCCKKQTWVYUMQWVSRIGGDGEGMYGBDYHPGZXVLBDEESUJNCJTUZMKGJJUQAMHDMKIQ MCDLTVHGEKWZZVPPXJEPLOYKBWPYEPILVNNEMINITOFHFACKCKUNFXZFUUBQYPHOCKOCOIMBMLXNAAWMKEUBBVMAXCBVFALP OWATAXAFB...
result:
ok 96 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
90 QVRHBGLGFBQQJZYICUKIXNUZRZXJWRHQRDKOPEXGBQXGFTTQCNOPALCXPTYDZWTQTKCECRTKEWGYTWMXHIURMLUYDP YHPXNNJDKHMYRUKHLPKOMEWODYRMOJNEHDJMDHEZVKQXTYBWVKCOJWHEYKNQIQJYUIHCNUDGNOVTDOQZAHRGWZOAXP BWGPZHSHHSEBWWGRTUVQEUZWUKCBWMQYOBPHPQTZYAGBNPMDDOTEPTVAZYTRSROQWXFLHMCRZAYIPAOHFQSLLQUAAW PSKKELFITHSHHGKIVZEEBLRZ...
output:
QVYBHRHPWPWSGXBGNPKKXRAPKZNLGJHEDGMMJWZMHLSDFBKHFTRFNGBYVDHIZRIHHQQMSTZUDZHREEZOWPZISKWHEY EBOYLFKUXQQASLTXBLTZUYXJRKAXOREIUEZRWMRUBZGEMBCTVNSSNZRBSCEVJIXTIWIKXODQAIRADCMWROBFAWCEZJ JEDHKPJQVVCMEURZCADOVJTRIVQDXTUECSVIJWFOBABSVBFIZCRKUQHUKNUMJBUMWLWNKWRSLVXPHXGEQIOFIXGSVZ FPNVQBHBYCPIHKIEPBTJUAJNLPX...
result:
ok 90 lines
Extra Test:
score: 0
Extra Test Passed