#include<bits/stdc++.h>
#include "arithmetics.h"
using namespace std;
#define pii pair<int, int>
typedef complex<int> point;
const int MAX_C= 100;
const int MAX_R =100;
pii dp[MAX_C][MAX_C][MAX_R];
void chmax(pii& a, pii& b){
if(b.first<a.first){
a= b;
}
else if(b.first == a.first){
a.second = Add(a.second, b.second);
}
}
signed main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int r, c, q;
cin>>r>>c>>q;
for(int fin= 0; fin<c; fin++){
dp[fin][0][fin] = {0, 1};
for(int line = 1; line<r; line++){
for(int j= 0; j<c; j++){
dp[fin][line][j] = dp[fin][line-1][j];
if(j>0){
chmax(dp[fin][line][j], dp[fin][line-1][j-1]);
}
if(j<c-1){
chmax(dp[fin][line][j], dp[fin][line-1][j+1]);
}
dp[fin][line][j].first++;
}
}
}
for(int i = 0; i<q; i++){
char p;
cin>>p;
int begin, dest;
cin>>begin>>dest;
begin--;
dest--;
if(p == 'K'){
cout<<dp[dest][r-1][begin].first<<" "<<dp[dest][r-1][begin].second<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4700 KB |
Output is correct |
2 |
Correct |
15 ms |
8028 KB |
Output is correct |
3 |
Correct |
11 ms |
7512 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4700 KB |
Output is correct |
2 |
Correct |
15 ms |
8028 KB |
Output is correct |
3 |
Correct |
11 ms |
7512 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
3 ms |
4700 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
10 ms |
7516 KB |
Output is correct |
8 |
Correct |
12 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4700 KB |
Output is correct |
2 |
Correct |
15 ms |
8028 KB |
Output is correct |
3 |
Correct |
11 ms |
7512 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
3 ms |
4700 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
10 ms |
7516 KB |
Output is correct |
8 |
Correct |
12 ms |
8284 KB |
Output is correct |
9 |
Runtime error |
12 ms |
16324 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4700 KB |
Output is correct |
2 |
Correct |
15 ms |
8028 KB |
Output is correct |
3 |
Correct |
11 ms |
7512 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
3 ms |
4700 KB |
Output is correct |
6 |
Correct |
2 ms |
4440 KB |
Output is correct |
7 |
Correct |
10 ms |
7516 KB |
Output is correct |
8 |
Correct |
12 ms |
8284 KB |
Output is correct |
9 |
Runtime error |
12 ms |
16324 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |