Code Submission Evaluation System Login

Datatähti 2015 loppu

Start:2015-01-29 12:15:00
End:2015-01-29 17:15:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2015 loppu - Results
History
2016-11-26 16:32:30?
2016-11-26 16:31:10?
2016-01-02 13:49:1859
2015-01-29 14:01:0917
2015-01-29 13:20:0817
2015-01-29 13:20:0517
2015-01-29 13:17:120
2015-01-29 13:09:210
2015-01-29 13:07:230
2015-01-29 13:04:110
Task:Ruudukko
Sender:Kuha
Submission time:2015-01-29 14:01:09
Language:Java
Status:READY
Score:17

Feedback

groupverdictscore
#1ACCEPTED17
#2TIME LIMIT EXCEEDED0
#3TIME LIMIT EXCEEDED0

Test results

testverdicttime (s)group
#1ACCEPTED0.03 / 3.001details
#2ACCEPTED0.04 / 3.001details
#3ACCEPTED0.02 / 3.001details
#4ACCEPTED0.03 / 3.001details
#5ACCEPTED0.01 / 3.001details
#6TIME LIMIT EXCEEDED-- / 3.002details
#7TIME LIMIT EXCEEDED-- / 3.002details
#8ACCEPTED0.06 / 3.002details
#9WRONG ANSWER0.05 / 3.002details
#10ACCEPTED0.05 / 3.002details
#11TIME LIMIT EXCEEDED-- / 3.003details
#12TIME LIMIT EXCEEDED-- / 3.003details
#13WRONG ANSWER0.27 / 3.003details
#14ACCEPTED0.27 / 3.003details
#15WRONG ANSWER0.26 / 3.003details

Code

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    private static int n;
    private static int x = 0;
    private static int y = 0;
    private static int[][] dir;
    
    public static void main(String[] args) {
        IO io = new IO();
        
        n = io.nextInt();
        
        dir = new int[n][n];
        char[][] arr = new char[n][n];
        
        for (int p = 0; p < n; p++) {
            String s = io.next();
            for (int o = 0; o < n; o++) {
                arr[p][o] = s.charAt(o);
            }
        }
        
        String str = "" + arr[0][0];
        
        while (x != n - 1 || y != n - 1) {
            if (dir[y][x] == 0) {
                int tempX = x;
                int tempY = y;
                next(arr, tempX, tempY, true, 1);
            } else if (dir[y][x] == 1) {
                x++;
                str += arr[y][x];
            } else {
                y++;
                str += arr[y][x];
            }
        }
        
        io.println(str);
        
        io.close();
    }
    
    private static char next (char[][] arr, int tx, int ty, boolean first, int iter) {
        if (tx == n - 1 && ty == n - 1) {
            return arr[ty][tx];
        } else if (tx == n - 1) {
            dir[ty][tx] = 2;
            ty++;
        } else if (ty == n - 1) {
            dir[ty][tx] = 1;
            tx++;
        } else {
            char cy = arr[ty + 1][tx];
            char cx = arr[ty][tx + 1];
            if (cy < cx) {
                dir[ty][tx] = 2;
                ty++;
            } else if (cx < cy) {
                dir[ty][tx] = 1;
                tx++;
            } else {
                int tempX = tx;
                int tempY = ty;
                char nx = next(arr, tempX + 1, tempY, false, iter + 1);
                char ny = next(arr, tempX, tempY + 1, false, iter + 1);
                if (ny < nx) {
                    dir[ty][tx] = 2;
                    ty++;
                } else if (nx < ny) {
                    dir[ty][tx] = 1;
                    tx++;
                } else {
                    dir[ty][tx] = 1;
                    tx++;
                }
            }
        }
        return arr[ty][tx];
    }
}

class IO extends PrintWriter {
	private InputStreamReader r;
	private static final int BUFSIZE = 1 << 15;
	private char[] buf;
	private int bufc;
	private int bufi;
	private StringBuilder sb;
	
	public IO() {
		super(new BufferedOutputStream(System.out));
		r = new InputStreamReader(System.in);
		
		buf = new char[BUFSIZE];
		bufc = 0;
		bufi = 0;
		sb = new StringBuilder();
	}
	
	private void fillBuf() throws IOException {
		bufi = 0;
		bufc = 0;
		while(bufc == 0) {
			bufc = r.read(buf, 0, BUFSIZE);
			if(bufc == -1) {
				bufc = 0;
				return;
			}
		}
	}
	
	private boolean pumpBuf() throws IOException {
		if(bufi == bufc) {
			fillBuf();
		}
		return bufc != 0;
	}
	
	private boolean isDelimiter(char c) {
		return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f';
	}
	
	private void eatDelimiters() throws IOException {
		while(true) {
			if(bufi == bufc) {
				fillBuf();
				if(bufc == 0) throw new RuntimeException("IO: Out of input.");
			}
			
			if(!isDelimiter(buf[bufi])) break;
			++bufi;
		}
	}
	
	public String next() {
		try {
			sb.setLength(0);
			
			eatDelimiters();
			int start = bufi;
			
			while(true) {
				if(bufi == bufc) {
					sb.append(buf, start, bufi - start);
					fillBuf();
					start = 0;
					if(bufc == 0) break;
				}
				
				if(isDelimiter(buf[bufi])) break;
				++bufi;
			}
			
			sb.append(buf, start, bufi - start);
			
			return sb.toString();
		} catch(IOException e) {
			throw new RuntimeException("IO.next: Caught IOException.");
		}
	}
	
	public int nextInt() {
		try {
			int ret = 0;
			
			eatDelimiters();
			
			boolean positive = true;
			if(buf[bufi] == '-') {
				++bufi;
				if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int.");
				positive = false;
			}
			
			boolean first = true;
			while(true) {
				if(!pumpBuf()) break;
				if(isDelimiter(buf[bufi])) {
					if(first) throw new RuntimeException("IO.nextInt: Invalid int.");
					break;
				}
				first = false;
				
				if(buf[bufi] >= '0' && buf[bufi] <= '9') {
					if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int.");
					ret *= 10;
					ret -= (int)(buf[bufi] - '0');
					if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int.");
				} else {
					throw new RuntimeException("IO.nextInt: Invalid int.");
				}
				
				++bufi;
			}
			
			if(positive) {
				if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int.");
				ret = -ret;
			}
			
			return ret;
		} catch(IOException e) {
			throw new RuntimeException("IO.nextInt: Caught IOException.");
		}
	}
	
	public long nextLong() {
		try {
			long ret = 0;
			
			eatDelimiters();
			
			boolean positive = true;
			if(buf[bufi] == '-') {
				++bufi;
				if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long.");
				positive = false;
			}
			
			boolean first = true;
			while(true) {
				if(!pumpBuf()) break;
				if(isDelimiter(buf[bufi])) {
					if(first) throw new RuntimeException("IO.nextLong: Invalid long.");
					break;
				}
				first = false;
				
				if(buf[bufi] >= '0' && buf[bufi] <= '9') {
					if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long.");
					ret *= 10;
					ret -= (long)(buf[bufi] - '0');
					if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long.");
				} else {
					throw new RuntimeException("IO.nextLong: Invalid long.");
				}
				
				++bufi;
			}
			
			if(positive) {
				if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long.");
				ret = -ret;
			}
			
			return ret;
		} catch(IOException e) {
			throw new RuntimeException("IO.nextLong: Caught IOException.");
		}
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
5
AAAAA
AAAAA
AAAAA
AAAAA
...
view   save

correct output
AAAAAAAAB

view   save

user output
AAAAAAAAB

view   save

Test 2

Group: 1

Verdict: ACCEPTED

input
5
ABABA
BABAB
ABABA
BABAB
...
view   save

correct output
ABABABABA

view   save

user output
ABABABABA

view   save

Test 3

Group: 1

Verdict: ACCEPTED

input
5
WRYIU
TWLKH
UJMJC
GRDJW
...
view   save

correct output
WRWJMDJWK

view   save

user output
WRWJMDJWK

view   save

Test 4

Group: 1

Verdict: ACCEPTED

input
5
RUEAE
ZYHHW
KDBPD
DXREW
...
view   save

correct output
RUEAEWDWX

view   save

user output
RUEAEWDWX

view   save

Test 5

Group: 1

Verdict: ACCEPTED

input
5
SRGYR
MYDOB
GNOVM
SZOZK
...
view   save

correct output
SMGNOOLTU

view   save

user output
SMGNOOLTU

view   save

Test 6

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
(empty)

Test 7

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
100
ABABABABABABABABABABABABABABAB...
view   save

correct output
ABABABABABABABABABABABABABABAB...
view   save

user output
(empty)

Test 8

Group: 2

Verdict: ACCEPTED

input
100
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC...
view   save

correct output
FWDBDECKBHKIACOVUCJGDJOHAYIBHO...
view   save

user output
FWDBDECKBHKIACOVUCJGDJOHAYIBHO...
view   save

Test 9

Group: 2

Verdict: WRONG ANSWER

input
100
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK...
view   save

correct output
EAARGLBRLHCDHHBPABHDAJBEEBHQBE...
view   save

user output
EAARGLBRLHCDHHBPABHDAJBEEBHQBE...
view   save

Test 10

Group: 2

Verdict: ACCEPTED

input
100
GNWMLJNHSBAADUFCSGIZMWHZTVDHNR...
view   save

correct output
GEGOFRDKBNLLEUOPOEQCEFMTKANLNC...
view   save

user output
GEGOFRDKBNLLEUOPOEQCEFMTKANLNC...
view   save

Test 11

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
500
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
view   save

user output
(empty)

Test 12

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
500
ABABABABABABABABABABABABABABAB...
view   save

correct output
ABABABABABABABABABABABABABABAB...
view   save

user output
(empty)

Test 13

Group: 3

Verdict: WRONG ANSWER

input
500
HGADXTSFXYIEMDWMFIVQGHTACFUPYI...
view   save

correct output
HGADEJOGAKPJCRAHTABRSDLAVGBFAG...
view   save

user output
HGADEJOGAKPJCRAHTABRSDLAVGBFAG...
view   save

Test 14

Group: 3

Verdict: ACCEPTED

input
500
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS...
view   save

correct output
SBLCAMDHILGIDRCIDUNMMAHFYCENOS...
view   save

user output
SBLCAMDHILGIDRCIDUNMMAHFYCENOS...
view   save

Test 15

Group: 3

Verdict: WRONG ANSWER

input
500
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ...
view   save

correct output
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD...
view   save

user output
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD...
view   save