QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#342235 | #8278. Secret Poems | Gen1us | AC ✓ | 1ms | 3812kb | C++14 | 3.5kb | 2024-03-01 09:58:04 | 2024-03-01 09:58:04 |
Judging History
answer
// Online C++ compiler to run C++ program online
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main() {
int n;
int s=0;
cin >> n;
vector<vector<char>> a(n+2, vector<char>(n+2, ' '));
char *b = new char[n*n+1];
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
cin >> a[i][j];
}
}
for(int i=0; i<=n+1; i++) {
a[0][i]=' ';
a[n+1][i]=' ';
a[i][0]=' ';
a[i][n+1]=' ';
}
bool right=true, bottom_left=false, bottom=false, top_right=false;
int i=1, j=1;
b[1]=a[1][1];
int element=2;
while(element<=(n*(n+1)/2)) {
if(right) j++;
if(bottom_left) {
i++;
j--;
}
if(bottom) i++;
if(top_right) {
i--;
j++;
}
b[element]=a[i][j];
element++;
if(right) {
right=false;
bottom_left=true;
goto next;
}
if(bottom_left && a[i+1][j-1]==' ') {
bottom_left=false;
bottom=true;
goto next;
}
if(bottom) {
bottom=false;
top_right=true;
goto next;
}
if(top_right && a[i-1][j+1]==' ') {
top_right=false;
right=true;
goto next;
}
next:
s++;
}
if(n%2) {
right=false;
bottom=true;
}
if(n%2==0) {
bottom=false;
right=true;
}
while(element<=n*n) {
if(right) j++;
if(bottom_left) {
i++;
j--;
}
if(bottom) i++;
if(top_right) {
i--;
j++;
}
b[element]=a[i][j];
element++;
if(right) {
right=false;
top_right=true;
goto end;
}
if(bottom_left && a[i+1][j-1]==' ') {
bottom_left=false;
right=true;
goto end;
}
if(bottom) {
bottom=false;
bottom_left=true;
goto end;
}
if(top_right && a[i-1][j+1]==' ') {
top_right=false;
bottom=true;
goto end;
}
end:
s++;
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
a[i][j]=0;
}
}
for(int i=0; i<=n+1; i++) {
a[0][i]=1;
a[n+1][i]=1;
a[i][0]=1;
a[i][n+1]=1;
}
right=true;
bool left=false;
bottom=false;
bool top=false;
i=1, j=0;
element=1;
while(element<=n*n) {
if(right) j++;
if(left) j--;
if(bottom) i++;
if(top) i--;
a[i][j]=b[element];
element++;
if(right && a[i][j+1]) {
right=false;
bottom=true;
goto hi;
}
if(left && a[i][j-1]) {
left=false;
top=true;
goto hi;
}
if(bottom && a[i+1][j]) {
bottom=false;
left=true;
goto hi;
}
if(top && a[i-1][j]) {
top=false;
right=true;
goto hi;
}
hi:
s++;
}
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
cout << a[i][j];
}
cout << "\n";
}
a.clear();
delete [] b;
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3580kb
input:
2 AB CD
output:
AB DC
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
4 ABCD EFGH IJKL MNOP
output:
ABEI KHLF NPOC MJGD
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
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: 3620kb
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: 3584kb
input:
100 XIZRFKBGIFYHQYTINRAKHBPJVQGJIJQXTBLLBVNQQQTSAKPIXTORIREMDTGNDFTOZGUZICOMGINGXDXQXYQEWRNCYEDQCQZHKOIB DNOXVOJOCZMMMAVEWUBXSRPTRNQYWWNGIPKSSRRSBJVKJTAFHQTLJXRWEAZIPYYHSOOTJNJWROQLKUUXBDYKEWKCGGVKFYUWEJWA MIJFNAGSVCXQVEUKOKADMISAQIUNIRHMOVQUPREHRYLSVCTDMTDBEUOYEDJNAQGAMDPLLVAMNARRTYQQERKKBOMPGEEYBC...
output:
XIDMNZROISHWJXFKVFOMPBLMSNOBGJANSFUSGKDSGMGOIFCSFFMKRXJLQYULMBGVZYHMCIYDVHARLNXOHNCRFLUQXMQYMQBMZUGI VXJKKIEEMEBNESRILIGJZXDTTPBGTLEFJMJIRUYIJWNXRTNIBFPKEMPYDRHWRMJMDRBGRFWXIOYGRKJVXIMZUCWBZTHSJHOJWIIP GUWMZUKXPUVAMPLTZXTDHTRJKWJWUDGAHTRLUVBQOWXPZHWGVAORKJKTPZWOLWQSFSVQQKTQBRZUESQQBHIEEBUBSRGTQRHIGL...
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
99 KQAUNRTKSNBKSOZMISHVIOTCGFRXRTSERIDJIRBWSUBUSHDCYSRJRGFUAEDPPSSYICZTADUFWNQWOYJXSIWPKORVPXNNIATPFMI TYVXVKQOAHAAZHKIBRXTQMPAGYJRILVGWJIWSAKLVUFDMWXTWPXNDSUMKKNAXDIOKHMOBYCFEXHWQDQHPRAYKDOPDJZZAJVNNAL PHPSTAHBZPCVMEFZJYRIOEZFBYVEVUEXNFEQBONIRFGGKPJXOMHVVRWJWOQFCKLQWBRZUVPSUVNKMDGNFMMENZDWPCZZXNXSI...
output:
KQTPYAUVHCPCPXNRVSHVOOXGPTKTKQARHSKDXDRRDWHOSNABFPUDNTFLEFXSJBFZHBKAPYBNETSZYWKAWFTXPBQACASOZVKUZEK MFXDKJWJFYDGYLNSEVKRYOAYTWVROFEDJZEJXNWKRVRRTIERMPSIRXQMIXFZRFUBRILBNGQJROPQBAXKCTCOKYRAOLTPECOXBTC GZXBABWKOCZAOQBKENWFFRFBXOOCQZAXONHAWHXLJPZDLDBYAFKPZBLXVZQUJWTPNGRCDKYRJRWNIIUECLMBNLSUVIEMGJPGBVG ...
result:
ok 99 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
98 AWIITUWKFFFFJJAFYGXBSDMHLXUENBIGWUUXSQMWRIOOFYIECDJVUCRUUFWXDRQMJPUPJVJOIRVCURIVIAJPPWDSCYLZBNSRRL OVLTIENSFNUSITTHGHASWIHFEQSDYSFFSASKUUJZSMKNKGBDXZGTHPVRNQWDGTYNXMDLZICESKPMOCSLSVLELDVKYWOQFPUNRH RZGYHTYLPROGTRHSTZOJKRHQGJOQRHZUCGPJQBRUKHBMPUEIVMILPRUKKYFOUJWUYBCNNVHJHWRKAANOCOABIMZCJLGMFJAJDU ...
output:
AWORVIILZUVZGTTUIYHZXJAAHHEWKNTKQKWGMXZMRKYSFFFLNEWCSKTDNUODOLXPNFFURVHEUDXQMZYPRFQLIKQOOSJJIGTZKN TCGXALVYNTYWRQKMDYFQCWVCLLIWAEHGXAMDVBGDFTTFXODNBYQCTFRTNAENUSLKKIMBHFWVGJJCGPBMPSECFDCIDQFIAASLWT BMNDJLLRQKLQUMWJBZOKXODRSJCXAITJNLGFZJCHJULZQQUFAFUKBAVUPIMFTWLEPAISOLMLDXZLHGFXSALVXGOHZBQSRZRINR KBP...
result:
ok 98 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
96 GTHPKKJKUAIXLVQNDZGHHPPURUOMMYWDZVHHNCPIIDOFYXREYSUKPDHPINGMVXWPOWAAJJKIUKIVCIKDZDHUTZDNETZEZJFU HBORTXEIITFJNMZFIQMNVPRXAEMGGHCFKGEAUELEICWYIFUCMKEJHVURPDMQUOWPRDCHQEAKOUHLCEHJSMMTDGLVJRNXQPTO TLKETIQMYASQZUMUFBUYONKMGEEBMIBKGEGTYVDWTGAFFQAFQJDUKIVDHOSTKCDCKZMGKRMRBFUVFMREQWBFLVHQLUFLMTYV GHQSRN...
output:
GTHTBHPOLGXHKRKKTEQKNKOZSTXJKEIRQLSIYWKJWNQIUAIMBRMHDWBPABSPOQFYTIXFAFTUFYNEWMTQGPOSXOLPSJLVNQWL MEGBWAZQHNVNOTUJCDSRXCPHGPWNYKZDCCKKQTWVYUMQWVSRIGGDGEGMYGBDYHPGZXVLBDEESUJNCJTUZMKGJJUQAMHDMKIQ MCDLTVHGEKWZZVPPXJEPLOYKBWPYEPILVNNEMINITOFHFACKCKUNFXZFUUBQYPHOCKOCOIMBMLXNAAWMKEUBBVMAXCBVFALP OWATAXAFB...
result:
ok 96 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
90 QVRHBGLGFBQQJZYICUKIXNUZRZXJWRHQRDKOPEXGBQXGFTTQCNOPALCXPTYDZWTQTKCECRTKEWGYTWMXHIURMLUYDP YHPXNNJDKHMYRUKHLPKOMEWODYRMOJNEHDJMDHEZVKQXTYBWVKCOJWHEYKNQIQJYUIHCNUDGNOVTDOQZAHRGWZOAXP BWGPZHSHHSEBWWGRTUVQEUZWUKCBWMQYOBPHPQTZYAGBNPMDDOTEPTVAZYTRSROQWXFLHMCRZAYIPAOHFQSLLQUAAW PSKKELFITHSHHGKIVZEEBLRZ...
output:
QVYBHRHPWPWSGXBGNPKKXRAPKZNLGJHEDGMMJWZMHLSDFBKHFTRFNGBYVDHIZRIHHQQMSTZUDZHREEZOWPZISKWHEY EBOYLFKUXQQASLTXBLTZUYXJRKAXOREIUEZRWMRUBZGEMBCTVNSSNZRBSCEVJIXTIWIKXODQAIRADCMWROBFAWCEZJ JEDHKPJQVVCMEURZCADOVJTRIVQDXTUECSVIJWFOBABSVBFIZCRKUQHUKNUMJBUMWLWNKWRSLVXPHXGEQIOFIXGSVZ FPNVQBHBYCPIHKIEPBTJUAJNLPX...
result:
ok 90 lines
Extra Test:
score: 0
Extra Test Passed