This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |