CSES - Datatähti 2015 loppu - Results
Submission details
Task:Ruudukko
Sender:Ollie
Submission time:2015-01-29 13:26:48 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.06 s1details
#2ACCEPTED0.07 s1details
#30.06 s1details
#40.06 s1details
#50.07 s1details
#6ACCEPTED0.06 s2details
#70.07 s2details
#80.06 s2details
#90.08 s2details
#100.07 s2details
#11ACCEPTED0.10 s3details
#120.11 s3details
#130.11 s3details
#140.10 s3details
#150.11 s3details

Code

#include <bits/stdc++.h>

#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>

using namespace std;

char c[501][501];
int ns[501][501];
pair<int,int> ls[501][501];

int main() {
	cin.tie(0);
	
	int n; cin >> n;
	for(int y=0;y<n;y++) {
		for(int x=0;x<n;x++) {
			char a; cin >> a;
			c[x][y] = a;
			ns[x][y] = 6500005;
		}
	}
	
	for(int y=0;y<n;y++) {
		for(int x=0;x<n;x++) {
		int n1=0,n2=0;
		if(y>0) { n1 = ns[x][y-1]; }
		if(x>0) { n2 = ns[x-1][y]; }
		int p = min(n1,n2)+(c[x][y]-'A'+1);
		if(p<ns[x][y]) {
			ns[x][y] = p;
			pair<int,int> from;
			if(y==0&&x==0) from = mp(-1,-1);
			else if(y==0&&x>0) from=mp(x-1,y);
			else if(x==0&&y>0) from = mp(x,y-1);
			else if(n1<n2) from=mp(x,y-1);
			else from=mp(x-1,y); 
			ls[x][y] = from;
		}
		}
	}
	
	string fstring="";
	int x=n-1,y=n-1;
	while(true) {;
		fstring += c[x][y];
		int tx = ls[x][y].first;
		int ty = ls[x][y].second;
		x=tx;y=ty;
		if(x==-1&&y==-1) break;
	} 
	reverse(fstring.begin(), fstring.end());
	cout << fstring << endl;
	
	return 0;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
5
AAAAA
AAAAA
AAAAA
AAAAA
...

correct output
AAAAAAAAB

user output
AAAAAAAAB

Test 2

Group: 1

Verdict: ACCEPTED

input
5
ABABA
BABAB
ABABA
BABAB
...

correct output
ABABABABA

user output
ABABABABA

Test 3

Group: 1

Verdict:

input
5
WRYIU
TWLKH
UJMJC
GRDJW
...

correct output
WRWJMDJWK

user output
WTUGFKKYK

Test 4

Group: 1

Verdict:

input
5
RUEAE
ZYHHW
KDBPD
DXREW
...

correct output
RUEAEWDWX

user output
RUEAHPEGX

Test 5

Group: 1

Verdict:

input
5
SRGYR
MYDOB
GNOVM
SZOZK
...

correct output
SMGNOOLTU

user output
SMGSFFLTU

Test 6

Group: 2

Verdict: ACCEPTED

input
100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

Test 7

Group: 2

Verdict:

input
100
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
ABABABABABABABABABABABABABABAB...

Test 8

Group: 2

Verdict:

input
100
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC...

correct output
FWDBDECKBHKIACOVUCJGDJOHAYIBHO...

user output
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC...

Test 9

Group: 2

Verdict:

input
100
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK...

correct output
EAARGLBRLHCDHHBPABHDAJBEEBHQBE...

user output
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK...

Test 10

Group: 2

Verdict:

input
100
GNWMLJNHSBAADUFCSGIZMWHZTVDHNR...

correct output
GEGOFRDKBNLLEUOPOEQCEFMTKANLNC...

user output
GEGXCGQWZXFRKXTUKUMRBETITVUXOP...

Test 11

Group: 3

Verdict: ACCEPTED

input
500
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

Test 12

Group: 3

Verdict:

input
500
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
ABABABABABABABABABABABABABABAB...

Test 13

Group: 3

Verdict:

input
500
HGADXTSFXYIEMDWMFIVQGHTACFUPYI...

correct output
HGADEJOGAKPJCRAHTABRSDLAVGBFAG...

user output
HTYSAYZJIIKFMNUNZHWRECRLQOZAPI...

Test 14

Group: 3

Verdict:

input
500
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS...

correct output
SBLCAMDHILGIDRCIDUNMMAHFYCENOS...

user output
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS...

Test 15

Group: 3

Verdict:

input
500
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ...

correct output
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD...

user output
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ...