Task: | Ruudukko |
Sender: | Ollie |
Submission time: | 2015-01-29 13:26:48 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.06 s | 1 | details |
#2 | ACCEPTED | 0.07 s | 1 | details |
#3 | WRONG ANSWER | 0.06 s | 1 | details |
#4 | WRONG ANSWER | 0.06 s | 1 | details |
#5 | WRONG ANSWER | 0.07 s | 1 | details |
#6 | ACCEPTED | 0.06 s | 2 | details |
#7 | WRONG ANSWER | 0.07 s | 2 | details |
#8 | WRONG ANSWER | 0.06 s | 2 | details |
#9 | WRONG ANSWER | 0.08 s | 2 | details |
#10 | WRONG ANSWER | 0.07 s | 2 | details |
#11 | ACCEPTED | 0.10 s | 3 | details |
#12 | WRONG ANSWER | 0.11 s | 3 | details |
#13 | WRONG ANSWER | 0.11 s | 3 | details |
#14 | WRONG ANSWER | 0.10 s | 3 | details |
#15 | WRONG ANSWER | 0.11 s | 3 | details |
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: WRONG ANSWER
input |
---|
5 WRYIU TWLKH UJMJC GRDJW ... |
correct output |
---|
WRWJMDJWK |
user output |
---|
WTUGFKKYK |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 RUEAE ZYHHW KDBPD DXREW ... |
correct output |
---|
RUEAEWDWX |
user output |
---|
RUEAHPEGX |
Test 5
Group: 1
Verdict: WRONG ANSWER
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: WRONG ANSWER
input |
---|
100 ABABABABABABABABABABABABABABAB... |
correct output |
---|
ABABABABABABABABABABABABABABAB... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
Test 8
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 FWOVNYKNMMQCNHJGUYPNEDXGVVGONC... |
correct output |
---|
FWDBDECKBHKIACOVUCJGDJOHAYIBHO... |
user output |
---|
FWOVNYKNMMQCNHJGUYPNEDXGVVGONC... |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
100 ETGCJABWKMAAEOQXWFFYMDJBMNKMQK... |
correct output |
---|
EAARGLBRLHCDHHBPABHDAJBEEBHQBE... |
user output |
---|
ETGCJABWKMAAEOQXWFFYMDJBMNKMQK... |
Test 10
Group: 2
Verdict: WRONG ANSWER
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: WRONG ANSWER
input |
---|
500 ABABABABABABABABABABABABABABAB... |
correct output |
---|
ABABABABABABABABABABABABABABAB... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
Test 13
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 HGADXTSFXYIEMDWMFIVQGHTACFUPYI... |
correct output |
---|
HGADEJOGAKPJCRAHTABRSDLAVGBFAG... |
user output |
---|
HTYSAYZJIIKFMNUNZHWRECRLQOZAPI... |
Test 14
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 SBLNMAZESQVGWAPZYHQJMQTNGMEZWS... |
correct output |
---|
SBLCAMDHILGIDRCIDUNMMAHFYCENOS... |
user output |
---|
SBLNMAZESQVGWAPZYHQJMQTNGMEZWS... |
Test 15
Group: 3
Verdict: WRONG ANSWER
input |
---|
500 AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ... |
correct output |
---|
AOJLDOAPBGEKSGCNKBUMKAJCCWCOOD... |
user output |
---|
AOXYXRYFWPYWQDPWXQITLHQQUAYZAJ... |