
 Code Submission Evaluation System 
Login 
HIIT Open 2018

Start:  20180526 11:00:00 
End:  20180526 16:00:00 


Tasks  Messages  Scoreboard  Statistics
CSES  HIIT Open 2018  Results
Task:  Find a Word 
Sender:  Tefyn virallinen maajoukkue 
Submission time:  20180526 15:17:30 
Language:  C++ 
Status:  READY 
Result:  ACCEPTED 
Test results
Code
#include <bits/stdc++.h>
using namespace std;
int n;
string s[33];
int64_t r[33][33];
string pp[33][33];
int np[33][33];
string hae(string lol, int64_t k, int64_t a, int64_t b, int i, int j){
//cout << lol+s[i][j] << " " << k << " " << a << " " << b << " " << i << " " << j << " " << np[i][j] << " " <<pp[i][j] << endl;
if(k < a  k >= b){
// cout << "re1" << endl;
return "";
}
if(i == n1 && j == n1){
if(k >= a && k < b)
return lol+s[i][j];
return "";
}
if(i < n1 && j < n1){
if(s[i+1][j] < s[i][j+1]){
int64_t down = r[i+1][j];
string re = hae(lol+s[i][j], k, a, a+down, i+1, j);
if(re.length() == 0){
re = hae(lol+s[i][j], k, a+down, b, i, j+1);
}
return re;
}
else if(s[i+1][j] > s[i][j+1]){
int64_t ri = r[i][j+1];
string re = hae(lol+s[i][j], k, a+ri, b, i+1, j);
if(re.length() == 0){
re = hae(lol+s[i][j], k, a, a+ri, i, j+1);
}
return re;
}
else {
int64_t ri = r[i][j+1];
int64_t down = r[i+1][j];
if(np[i][j] == 1){
string re3 = hae(lol+s[i][j], k, a, a+down, i+1, j);
if(re3.length() == 0){
re3 = hae(lol+s[i][j], k, a+down, b, i, j+1);
}
return re3;
}
else {
string re = hae(lol+s[i][j], k, a+ri, b, i+1, j);
if(re.length() == 0){
re = hae(lol+s[i][j], k, a, a+ri, i, j+1);
}
return re;
}
}
}
else if(i < n1){
return hae(lol+s[i][j], k, a, b, i+1, j);
}
else if(j < n1){
return hae(lol+s[i][j], k, a, b, i, j+1);
}
return "";
}
int main(){
int64_t k;
cin >> n >> k;
for(int i = 0; i < n; ++i)
cin >> s[i];
r[n1][n1] = 1;
pp[n1][n1] = s[n1][n1];
for(int i = n1; i >= 0; i){
for(int j = n1; j >= 0; j){
string c1 = "0";
c1[0] = 'Z'+1;
string c2 = "0";
c2[0] = 'Z'+1;
if(i < n1){
r[i][j] += r[i+1][j];
c1 = s[i][j]+pp[i+1][j];
}
if(j< n1){
r[i][j] += r[i][j+1];
c2 = s[i][j]+pp[i][j+1];
}
if(i < n1  j < n1){
if(c1 < c2){
np[i][j] = 1;
pp[i][j] = c1;
}
else{
pp[i][j] = c2;
}
}
//cout << i << " " << j << " " << pp[i][j] << endl;
}
}
cout << hae("", k1, 0, r[0][0], 0, 0) << endl;
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
input 

4 1
AAAA
AAAA
AAAA
AAAA 
Test 2
Verdict: ACCEPTED
input 

4 2
AAAA
AAAA
AAAA
AAAA 
Test 3
Verdict: ACCEPTED
input 

4 10
AAAA
AAAA
AAAA
AAAA 
Test 4
Verdict: ACCEPTED
input 

4 19
AAAA
AAAA
AAAA
AAAA 
Test 5
Verdict: ACCEPTED
input 

4 20
AAAA
AAAA
AAAA
AAAA 
Test 6
Verdict: ACCEPTED
input 

4 1
QNJP
EVJU
XHZF
RXCV 
Test 7
Verdict: ACCEPTED
input 

4 2
QNJP
EVJU
XHZF
RXCV 
Test 8
Verdict: ACCEPTED
input 

4 10
QNJP
EVJU
XHZF
RXCV 
Test 9
Verdict: ACCEPTED
input 

4 19
QNJP
EVJU
XHZF
RXCV 
Test 10
Verdict: ACCEPTED
input 

4 20
QNJP
EVJU
XHZF
RXCV 
Test 11
Verdict: ACCEPTED
input 

30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAA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ROAOVNBBNVDZNZHOZGCHYAFTHHWD
DWCDSGBQZKLLXWHHWGXJQWNWENIZWZ
... 
correct output 

QNXZYLYURTAYRYZQUKZCYOPKYKLQPX... 
user output 

QNXZYLYURTAYRYZQUKZCYOPKYKLQPX... 
Test 16
Verdict: ACCEPTED
input 

30 30067266499541040
QNJPEVJUXHZFRXCVKBSJKUURVPLYUI
RXLGFBNQPBKQQRQFHLXUIUPLUOUOQW
FZNNUBMTLXUMTSJOOGBDBEVEYVWOLP
WYLTEQJBJRPSEMPOESVKFTQKEMSIAP
QHYOUWFHLJQDVTGVCSIVHNPKDWNJQC
GBUFNYPCWYNPQQMADZXQPYTAUETQSU
LURTALUCESXQWEFCOXPGXBFUIOMFBW
RJPAYRYBOCQKHOHRAWHJTITBTBTUQK
EMREBEZQUEFPCFEAYNTCYIBSMVIUPI
SCOSBRKAKZBPLLZPPOYCZRUTADFQEF
VKIJFVWGOCYMDCFXSEBAGJIRSKNYSK
FEVSYNRBXCOHWXGIRQOPNAIVYLXQOE
JNABESJIUMPKLSDJKBIGOSGCEJKNRN
SYROUHKKNTCYGDSSTYBQBYPOWUQIHS
YXZKTSAPWXLKLQGSNKTPGEAQIAHFMC
BAGQPHLNARILPPVQUYQOMTHOXNIKMZ
NLDRZQIWUYFGQXWCIQOCRXFUPKZWWY
AAROAOVNBBNVDZNZHOZGCHYAFTHHWD
DWCDSGBQZKLLXWHHWGXJQWNWENIZWZ
... 
correct output 

QRXZYLYURTAYRYZQUKZCYOPKYKLQPX... 
user output 

QRXZYLYURTAYRYZQUKZCYOPKYKLQPX... 