
 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:  Karhukopla 
Submission time:  20180526 12:27:24 
Language:  C++ 
Status:  READY 
Result:  ACCEPTED 
Test results
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:24:22: warning: comparison between signed and unsigned integer expressions [Wsigncompare]
while (ans.length() != 2 * n  1) ans.push_back('Z');
~~~~~~~~~~~~~^~~~~~~~~~~~
Code
#include <bits/stdc++.h>
#define ll long long
#define lll __int128
#define pii pair<int, int>
#define M 1000000007
#define N 30
using namespace std;
lll dp[N][N];
lll eq[N][N];
char c[N][N];
int main () {
ll n, kk;
cin>>n>>kk;
lll k = kk;
string ans;
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) cin>>c[y][x];
}
while (ans.length() != 2 * n  1) ans.push_back('Z');
for (int i = 0; i < 2 * n  1; i++) {
bool b = true;
while (b) {
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) eq[y][x] = dp[y][x] = 0;
}
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
int p = y + x;
if (c[y][x] < ans[p]) {
if (p == 0) {
dp[y][x] = 1;
eq[y][x] = 0;
} else if (!y) {
dp[y][x] = dp[y][x  1] + eq[y][x  1];
eq[y][x] = 0;
} else if (!x) {
dp[y][x] = dp[y  1][x] + eq[y  1][x];
eq[y][x] = 0;
} else {
dp[y][x] = dp[y  1][x] + dp[y][x  1] + eq[y  1][x] + eq[y][x  1];
eq[y][x] = 0;
}
} else if (c[y][x] == ans[p]) {
if (p == 0) {
dp[y][x] = 0;
eq[y][x] = 1;
} else if (!y) {
dp[y][x] = dp[y][x  1];
eq[y][x] = eq[y][x  1];
} else if (!x) {
dp[y][x] = dp[y  1][x];
eq[y][x] = eq[y  1][x];
} else {
dp[y][x] = dp[y  1][x] + dp[y][x  1];
eq[y][x] = eq[y  1][x] + eq[y][x  1];
}
} else if (c[y][x] > ans[p]) {
if (p == 0) {
dp[y][x] = 0;
eq[y][x] = 0;
} else if (!y) {
dp[y][x] = dp[y][x  1];
eq[y][x] = 0;
} else if (!x) {
dp[y][x] = dp[y  1][x];
eq[y][x] = 0;
} else {
dp[y][x] = dp[y  1][x] + dp[y][x  1];
eq[y][x] = 0;
}
}
}
}
if (dp[n  1][n  1] + eq[n  1][n  1] >= k) ans[i];
else break;
}
ans[i]++;
}
cout<<ans<<endl;
}
/**
AAU
YBA
BTY
*/
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
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAA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HHWGXJQWNWENIZWZ
... 
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... 