CSES - Datatähti 2015 loppu - Results
Submission details
Task:Ruudukko
Sender:Ollie
Submission time:2015-01-29 15:56:51 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.07 s1details
#30.06 s1details
#4ACCEPTED0.06 s1details
#50.06 s1details
#6--2details
#7--2details
#8--2details
#9--2details
#10--2details
#11--3details
#12--3details
#13--3details
#14--3details
#15--3details

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 n;
vector<string> ls;
int p[501][501];

void search(int x, int y,string s,int ff) {
	//cout << ff << endl;
	//cout << x << "," << y << endl;
	if(x>n||y>n) return;
	if(ff > p[x][y]) return;
	p[x][y] = ff;
	if(x==n-1&&y==n-1) ls.pb(s);
	search(x+1,y,s+c[x][y],ff+(int)c[x][y]);
	search(x,y+1,s+c[x][y],ff+(int)c[x][y]);
}

int main() {
	cin.tie(0);
	
	cin >> n;
	for(int y=0;y<n;y++) {
		for(int x=0;x<n;x++) {
			char a; cin >> a;
			c[x][y] = a;
			p[x][y] = 99999999;
		}
	}
	
	search(0,0,"",0);
	sort(ls.begin(), ls.end());
	string best = ls[0]+c[n-1][n-1];
	cout << best << 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
WRYIKHCWK

Test 4

Group: 1

Verdict: ACCEPTED

input
5
RUEAE
ZYHHW
KDBPD
DXREW
...

correct output
RUEAEWDWX

user output
RUEAEWDWX

Test 5

Group: 1

Verdict:

input
5
SRGYR
MYDOB
GNOVM
SZOZK
...

correct output
SMGNOOLTU

user output
SRGDOBMKU

Test 6

Group: 2

Verdict:

input
100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
(empty)

Test 7

Group: 2

Verdict:

input
100
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
(empty)

Test 8

Group: 2

Verdict:

input
100
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC...

correct output
FWDBDECKBHKIACOVUCJGDJOHAYIBHO...

user output
(empty)

Test 9

Group: 2

Verdict:

input
100
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK...

correct output
EAARGLBRLHCDHHBPABHDAJBEEBHQBE...

user output
(empty)

Test 10

Group: 2

Verdict:

input
100
GNWMLJNHSBAADUFCSGIZMWHZTVDHNR...

correct output
GEGOFRDKBNLLEUOPOEQCEFMTKANLNC...

user output
(empty)

Test 11

Group: 3

Verdict:

input
500
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

user output
(empty)

Test 12

Group: 3

Verdict:

input
500
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
(empty)

Test 13

Group: 3

Verdict:

input
500
HGADXTSFXYIEMDWMFIVQGHTACFUPYI...

correct output
HGADEJOGAKPJCRAHTABRSDLAVGBFAG...

user output
(empty)

Test 14

Group: 3

Verdict:

input
500
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS...

correct output
SBLCAMDHILGIDRCIDUNMMAHFYCENOS...

user output
(empty)

Test 15

Group: 3

Verdict:

input
500
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ...

correct output
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD...

user output
(empty)