QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343289#8278. Secret Poemsmendicillin2#AC ✓3ms8512kbC++172.0kb2024-03-02 13:25:482024-03-02 13:25:50

Judging History

你现在查看的是最新测评结果

  • [2024-03-02 13:25:50]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:8512kb
  • [2024-03-02 13:25:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

char ch[1100][1100], ans[11000];

int vis[1100][1100];

int main()
{
	int n = read();
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++) {
			cin >> ch[i][j];
		}
	int si = 1, sj = 1, f = 0;
	for (int i = 1; i <= n * n; i ++) {
		ans[i] = ch[si][sj];
		vis[si][sj] = 1;
		if (si == 1 && sj + 1 <= n && !f) {
			sj ++;
			f = 1;
			continue;
		}
		if (sj == 1 && si + 1 <= n && !f) {
			si ++;
			f = 1;
			continue;
		}
		if (sj == n && si + 1 <= n && !f) {
			si ++;
			f = 1;
			continue;
		}
		if (si == n && sj + 1 <= n && !f) {
			sj ++;
			f = 1;
			continue;
		}
		f = 0;
		if (!vis[si + 1][sj - 1] && si + 1 <= n && sj - 1 >= 1) {
			++si;
			--sj;
			continue;
		}
		if (!vis[si - 1][sj + 1] && si - 1 >= 1 && sj + 1 <= n) {
			--si;
			++sj;
			continue;
		}
	}
	si = 1; sj = 1; f = 0;
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i <= n + 1; i ++)
		for (int j = 0; j <= n + 1; j ++)
			vis[i][j] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j ++)
			vis[i][j] = 0;
	for (int i = 1; i <= n * n; i ++) {
		ch[si][sj] = ans[i];
		vis[si][sj] = 1;
		if (f == 0 && !vis[si][sj + 1]) {
			sj ++;
			continue;
		}
		if (f == 0 && vis[si][sj + 1]) f = 1;
		if (f == 1 && !vis[si + 1][sj]) {
			si ++;
			continue;
		}
		if (f == 1 && vis[si + 1][sj]) {
			f = 2;
		}
		if (f == 2 && !vis[si][sj - 1]) {
			sj --;
			continue;
		}
		if (f == 2 && vis[si][sj - 1]) {
			f = 3;
		}
		if (f == 3 && !vis[si - 1][sj]) {
			si --;
			continue;
		}
		if (f == 3 && vis[si - 1][sj]) {
			f = 0;
		}
		if (f == 0 && !vis[si][sj + 1]) {
			sj ++;
			continue;
		}
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++)
			cout << ch[i][j];
		cout <<'\n';
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 8316kb

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: 8284kb

input:

2
AB
CD

output:

AB
DC

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 8324kb

input:

4
ABCD
EFGH
IJKL
MNOP

output:

ABEI
KHLF
NPOC
MJGD

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 8424kb

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: 8300kb

input:

20
ABCDEFGHEFGHEFGHIJKL
EFGHIJKLMNOPKLMNKEFW
IJKLIAAAAJKLIJKLEEEE
EFGHIJKLMNOPKLMNKEFW
IJKLIAAAAJKLIJKLEEEE
IJKLIAAAAJKLIJKLEEEE
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RJKWJWUDGAHTRLUVBQOWXPZHWGVAORKJKTPZWOLWQSFSVQQKTQBRZUESQQBHIEEBUBSRGTQRHIGL...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 3ms
memory: 8400kb

input:

99
KQAUNRTKSNBKSOZMISHVIOTCGFRXRTSERIDJIRBWSUBUSHDCYSRJRGFUAEDPPSSYICZTADUFWNQWOYJXSIWPKORVPXNNIATPFMI
TYVXVKQOAHAAZHKIBRXTQMPAGYJRILVGWJIWSAKLVUFDMWXTWPXNDSUMKKNAXDIOKHMOBYCFEXHWQDQHPRAYKDOPDJZZAJVNNAL
PHPSTAHBZPCVMEFZJYRIOEZFBYVEVUEXNFEQBONIRFGGKPJXOMHVVRWJWOQFCKLQWBRZUVPSUVNKMDGNFMMENZDWPCZZXNXSI...

output:

KQTPYAUVHCPCPXNRVSHVOOXGPTKTKQARHSKDXDRRDWHOSNABFPUDNTFLEFXSJBFZHBKAPYBNETSZYWKAWFTXPBQACASOZVKUZEK
MFXDKJWJFYDGYLNSEVKRYOAYTWVROFEDJZEJXNWKRVRRTIERMPSIRXQMIXFZRFUBRILBNGQJROPQBAXKCTCOKYRAOLTPECOXBTC
GZXBABWKOCZAOQBKENWFFRFBXOOCQZAXONHAWHXLJPZDLDBYAFKPZBLXVZQUJWTPNGRCDKYRJRWNIIUECLMBNLSUVIEMGJPGBVG
...

result:

ok 99 lines

Test #8:

score: 0
Accepted
time: 3ms
memory: 8384kb

input:

98
AWIITUWKFFFFJJAFYGXBSDMHLXUENBIGWUUXSQMWRIOOFYIECDJVUCRUUFWXDRQMJPUPJVJOIRVCURIVIAJPPWDSCYLZBNSRRL
OVLTIENSFNUSITTHGHASWIHFEQSDYSFFSASKUUJZSMKNKGBDXZGTHPVRNQWDGTYNXMDLZICESKPMOCSLSVLELDVKYWOQFPUNRH
RZGYHTYLPROGTRHSTZOJKRHQGJOQRHZUCGPJQBRUKHBMPUEIVMILPRUKKYFOUJWUYBCNNVHJHWRKAANOCOABIMZCJLGMFJAJDU
...

output:

AWORVIILZUVZGTTUIYHZXJAAHHEWKNTKQKWGMXZMRKYSFFFLNEWCSKTDNUODOLXPNFFURVHEUDXQMZYPRFQLIKQOOSJJIGTZKN
TCGXALVYNTYWRQKMDYFQCWVCLLIWAEHGXAMDVBGDFTTFXODNBYQCTFRTNAENUSLKKIMBHFWVGJJCGPBMPSECFDCIDQFIAASLWT
BMNDJLLRQKLQUMWJBZOKXODRSJCXAITJNLGFZJCHJULZQQUFAFUKBAVUPIMFTWLEPAISOLMLDXZLHGFXSALVXGOHZBQSRZRINR
KBP...

result:

ok 98 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 8392kb

input:

96
GTHPKKJKUAIXLVQNDZGHHPPURUOMMYWDZVHHNCPIIDOFYXREYSUKPDHPINGMVXWPOWAAJJKIUKIVCIKDZDHUTZDNETZEZJFU
HBORTXEIITFJNMZFIQMNVPRXAEMGGHCFKGEAUELEICWYIFUCMKEJHVURPDMQUOWPRDCHQEAKOUHLCEHJSMMTDGLVJRNXQPTO
TLKETIQMYASQZUMUFBUYONKMGEEBMIBKGEGTYVDWTGAFFQAFQJDUKIVDHOSTKCDCKZMGKRMRBFUVFMREQWBFLVHQLUFLMTYV
GHQSRN...

output:

GTHTBHPOLGXHKRKKTEQKNKOZSTXJKEIRQLSIYWKJWNQIUAIMBRMHDWBPABSPOQFYTIXFAFTUFYNEWMTQGPOSXOLPSJLVNQWL
MEGBWAZQHNVNOTUJCDSRXCPHGPWNYKZDCCKKQTWVYUMQWVSRIGGDGEGMYGBDYHPGZXVLBDEESUJNCJTUZMKGJJUQAMHDMKIQ
MCDLTVHGEKWZZVPPXJEPLOYKBWPYEPILVNNEMINITOFHFACKCKUNFXZFUUBQYPHOCKOCOIMBMLXNAAWMKEUBBVMAXCBVFALP
OWATAXAFB...

result:

ok 96 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 8372kb

input:

90
QVRHBGLGFBQQJZYICUKIXNUZRZXJWRHQRDKOPEXGBQXGFTTQCNOPALCXPTYDZWTQTKCECRTKEWGYTWMXHIURMLUYDP
YHPXNNJDKHMYRUKHLPKOMEWODYRMOJNEHDJMDHEZVKQXTYBWVKCOJWHEYKNQIQJYUIHCNUDGNOVTDOQZAHRGWZOAXP
BWGPZHSHHSEBWWGRTUVQEUZWUKCBWMQYOBPHPQTZYAGBNPMDDOTEPTVAZYTRSROQWXFLHMCRZAYIPAOHFQSLLQUAAW
PSKKELFITHSHHGKIVZEEBLRZ...

output:

QVYBHRHPWPWSGXBGNPKKXRAPKZNLGJHEDGMMJWZMHLSDFBKHFTRFNGBYVDHIZRIHHQQMSTZUDZHREEZOWPZISKWHEY
EBOYLFKUXQQASLTXBLTZUYXJRKAXOREIUEZRWMRUBZGEMBCTVNSSNZRBSCEVJIXTIWIKXODQAIRADCMWROBFAWCEZJ
JEDHKPJQVVCMEURZCADOVJTRIVQDXTUECSVIJWFOBABSVBFIZCRKUQHUKNUMJBUMWLWNKWRSLVXPHXGEQIOFIXGSVZ
FPNVQBHBYCPIHKIEPBTJUAJNLPX...

result:

ok 90 lines

Extra Test:

score: 0
Extra Test Passed