QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#422014 | #8278. Secret Poems | ucup-team228# | AC ✓ | 1ms | 3904kb | C++20 | 3.3kb | 2024-05-26 16:33:20 | 2024-05-26 16:33:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string to_string(string a) { return '"' + a + '"'; }
string to_string(char a) { return "'" + string(1, a) + "'"; }
string to_string(const char* a) { return to_string((string) a); }
string to_string(bool a) { return a ? "true" : "false"; }
template <class T1, class T2>
string to_string(pair<T1, T2> a) {
return "(" + to_string(a.first) + ", " + to_string(a.second) + ")";
}
template <class T>
string to_string(T a) {
bool first = true; string res = "{";
for (const auto& i : a) {
if (!first) res += ", ";
first = false;
res += to_string(i);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <class T1, class... T2>
void debug_out(T1 a, T2... b) {
cerr << " " << to_string(a);
debug_out(b...);
}
#ifdef LOCAL
#define out(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define out(...) 42
#endif
clock_t start_time; void start_timer() { start_time = clock(); }
double get_time() { return (double) (clock() - start_time) / CLOCKS_PER_SEC; }
void Solve();
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("../input.txt", "r", stdin);
#endif
start_timer();
Solve();
#ifdef LOCAL
cerr << fixed << setprecision(3);
cerr << endl << "Time spent: " << get_time() << endl;
#endif
return 0;
}
const int N = 105;
char a[N][N];
char b[N][N];
bool used[N][N];
void Solve() {
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
used[i][j] = true;
}
}
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
used[i][j] = false;
}
}
{
int i = 1;
int j = 1;
int x = 1;
int y = 1;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ptr = 0;
for (int q = 1; q <= n * n; q++) {
b[x][y] = a[i][j];
used[x][y] = true;
if ((i + j) % 2 == 1) {
if (i + 1 <= n && j - 1 >= 1) {
i++;
j--;
}
else if (i < n) {
i++;
}
else {
j++;
}
}
else {
if (i - 1 >= 1 && j + 1 <= n) {
i--;
j++;
}
else if (j < n) {
j++;
}
else {
i++;
}
}
if (q < n * n) {
while (true) {
int nx = x + dx[ptr];
int ny = y + dy[ptr];
if (used[nx][ny]) {
ptr = (ptr + 1) % 4;
continue;
}
x = nx;
y = ny;
break;
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << b[i][j];
}
cout << "\n";
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3896kb
input:
2 AB CD
output:
AB DC
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
4 ABCD EFGH IJKL MNOP
output:
ABEI KHLF NPOC MJGD
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3680kb
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: 3872kb
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: 3720kb
input:
100 XIZRFKBGIFYHQYTINRAKHBPJVQGJIJQXTBLLBVNQQQTSAKPIXTORIREMDTGNDFTOZGUZICOMGINGXDXQXYQEWRNCYEDQCQZHKOIB DNOXVOJOCZMMMAVEWUBXSRPTRNQYWWNGIPKSSRRSBJVKJTAFHQTLJXRWEAZIPYYHSOOTJNJWROQLKUUXBDYKEWKCGGVKFYUWEJWA MIJFNAGSVCXQVEUKOKADMISAQIUNIRHMOVQUPREHRYLSVCTDMTDBEUOYEDJNAQGAMDPLLVAMNARRTYQQERKKBOMPGEEYBC...
output:
XIDMNZROISHWJXFKVFOMPBLMSNOBGJANSFUSGKDSGMGOIFCSFFMKRXJLQYULMBGVZYHMCIYDVHARLNXOHNCRFLUQXMQYMQBMZUGI VXJKKIEEMEBNESRILIGJZXDTTPBGTLEFJMJIRUYIJWNXRTNIBFPKEMPYDRHWRMJMDRBGRFWXIOYGRKJVXIMZUCWBZTHSJHOJWIIP GUWMZUKXPUVAMPLTZXTDHTRJKWJWUDGAHTRLUVBQOWXPZHWGVAORKJKTPZWOLWQSFSVQQKTQBRZUESQQBHIEEBUBSRGTQRHIGL...
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
99 KQAUNRTKSNBKSOZMISHVIOTCGFRXRTSERIDJIRBWSUBUSHDCYSRJRGFUAEDPPSSYICZTADUFWNQWOYJXSIWPKORVPXNNIATPFMI TYVXVKQOAHAAZHKIBRXTQMPAGYJRILVGWJIWSAKLVUFDMWXTWPXNDSUMKKNAXDIOKHMOBYCFEXHWQDQHPRAYKDOPDJZZAJVNNAL PHPSTAHBZPCVMEFZJYRIOEZFBYVEVUEXNFEQBONIRFGGKPJXOMHVVRWJWOQFCKLQWBRZUVPSUVNKMDGNFMMENZDWPCZZXNXSI...
output:
KQTPYAUVHCPCPXNRVSHVOOXGPTKTKQARHSKDXDRRDWHOSNABFPUDNTFLEFXSJBFZHBKAPYBNETSZYWKAWFTXPBQACASOZVKUZEK MFXDKJWJFYDGYLNSEVKRYOAYTWVROFEDJZEJXNWKRVRRTIERMPSIRXQMIXFZRFUBRILBNGQJROPQBAXKCTCOKYRAOLTPECOXBTC GZXBABWKOCZAOQBKENWFFRFBXOOCQZAXONHAWHXLJPZDLDBYAFKPZBLXVZQUJWTPNGRCDKYRJRWNIIUECLMBNLSUVIEMGJPGBVG ...
result:
ok 99 lines
Test #8:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
98 AWIITUWKFFFFJJAFYGXBSDMHLXUENBIGWUUXSQMWRIOOFYIECDJVUCRUUFWXDRQMJPUPJVJOIRVCURIVIAJPPWDSCYLZBNSRRL OVLTIENSFNUSITTHGHASWIHFEQSDYSFFSASKUUJZSMKNKGBDXZGTHPVRNQWDGTYNXMDLZICESKPMOCSLSVLELDVKYWOQFPUNRH RZGYHTYLPROGTRHSTZOJKRHQGJOQRHZUCGPJQBRUKHBMPUEIVMILPRUKKYFOUJWUYBCNNVHJHWRKAANOCOABIMZCJLGMFJAJDU ...
output:
AWORVIILZUVZGTTUIYHZXJAAHHEWKNTKQKWGMXZMRKYSFFFLNEWCSKTDNUODOLXPNFFURVHEUDXQMZYPRFQLIKQOOSJJIGTZKN TCGXALVYNTYWRQKMDYFQCWVCLLIWAEHGXAMDVBGDFTTFXODNBYQCTFRTNAENUSLKKIMBHFWVGJJCGPBMPSECFDCIDQFIAASLWT BMNDJLLRQKLQUMWJBZOKXODRSJCXAITJNLGFZJCHJULZQQUFAFUKBAVUPIMFTWLEPAISOLMLDXZLHGFXSALVXGOHZBQSRZRINR KBP...
result:
ok 98 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 3636kb
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