CSES - Datatähti 2015 loppu - Results
Submission details
Task:Ruudukko
Sender:Nameci2718_
Submission time:2015-01-29 16:11:28 +0200
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1details
#20.06 s1details
#30.03 s1details
#40.04 s1details
#50.03 s1details
#60.07 s2details
#70.05 s2details
#80.07 s2details
#90.10 s2details
#100.05 s2details
#110.46 s3details
#120.47 s3details
#130.47 s3details
#140.44 s3details
#150.44 s3details

Code


public class Main {

	public static void main(String[] args) {
		
		IO io = new IO();

		int n = io.nextInt();
		
		char[] characters = new char[n * n];
		
		for (int i = 0; i < n; i++) {
			char[] row = io.next().toCharArray();
			for (int j = 0; j < n; j++) {
				int index = j + i * n;
				characters[index] = row[j];
			}
		}
		
		String best = characters[0] + "";
		for (int i = 1; i < 2 * n - 1; i++) {
			int lowest = Integer.MAX_VALUE;
			for (int x = 0; x <= i; x++) {
				if(x >= n || i - x >= n) continue;
				int index = x + (i - x) * n;
				char left = ' ', up = ' ';
				if(x > 0) {
					left = characters[index-1];
				}
				if(i - x > 0) {
					up = characters[index-n];
				}
				char chr = characters[index];
				if(chr < lowest && 
						(up == best.charAt(best.length()-1) || left == best.charAt(best.length()-1))) lowest = chr;
			}
			best += lowest;
		}
		
		io.println(best);
		
		io.close();
		
	}

}

Test details

Test 1

Group: 1

Verdict:

input
5
AAAAA
AAAAA
AAAAA
AAAAA
...

correct output
AAAAAAAAB

user output
A65214748364721474836472147483...

Test 2

Group: 1

Verdict:

input
5
ABABA
BABAB
ABABA
BABAB
...

correct output
ABABABABA

user output
A66214748364721474836472147483...

Test 3

Group: 1

Verdict:

input
5
WRYIU
TWLKH
UJMJC
GRDJW
...

correct output
WRWJMDJWK

user output
W82214748364721474836472147483...

Test 4

Group: 1

Verdict:

input
5
RUEAE
ZYHHW
KDBPD
DXREW
...

correct output
RUEAEWDWX

user output
R85214748364721474836472147483...

Test 5

Group: 1

Verdict:

input
5
SRGYR
MYDOB
GNOVM
SZOZK
...

correct output
SMGNOOLTU

user output
S77214748364721474836472147483...

Test 6

Group: 2

Verdict:

input
100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
A65214748364721474836472147483...

Test 7

Group: 2

Verdict:

input
100
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
A66214748364721474836472147483...

Test 8

Group: 2

Verdict:

input
100
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC...

correct output
FWDBDECKBHKIACOVUCJGDJOHAYIBHO...

user output
F87214748364721474836472147483...

Test 9

Group: 2

Verdict:

input
100
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK...

correct output
EAARGLBRLHCDHHBPABHDAJBEEBHQBE...

user output
E65214748364721474836472147483...

Test 10

Group: 2

Verdict:

input
100
GNWMLJNHSBAADUFCSGIZMWHZTVDHNR...

correct output
GEGOFRDKBNLLEUOPOEQCEFMTKANLNC...

user output
G69214748364721474836472147483...

Test 11

Group: 3

Verdict:

input
500
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
A65214748364721474836472147483...

Test 12

Group: 3

Verdict:

input
500
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
A66214748364721474836472147483...

Test 13

Group: 3

Verdict:

input
500
HGADXTSFXYIEMDWMFIVQGHTACFUPYI...

correct output
HGADEJOGAKPJCRAHTABRSDLAVGBFAG...

user output
H71214748364721474836472147483...

Test 14

Group: 3

Verdict:

input
500
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS...

correct output
SBLCAMDHILGIDRCIDUNMMAHFYCENOS...

user output
S66214748364721474836472147483...

Test 15

Group: 3

Verdict:

input
500
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ...

correct output
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD...

user output
A79214748364721474836472147483...