#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ld>pairld;
typedef pair<string,ll>pairsl;
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
#define MOD 1000000007
#define INF 100000000000007
#define eps 0.00000000001
//#define A 30011
#define PI 3.14159265359
ll r,c,q,a[107][107],b[107][107],res[107][107];
void P(ll y){
while(y>0){
if(y%2==1){
for(int i=1;i<=c;i++){
for(int j=1;j<=c;j++){
b[i][j]=0;
//cout<<a[i][j]<<" ";
for(int k=1;k<=c;k++){
b[i][j]+=(res[i][k]*a[k][j])%MOD;
b[i][j]%=MOD;
}
}
//cout<<endl;
}
swap(res,b);
}
y/=2;
for(int i=1;i<=c;i++){
for(int j=1;j<=c;j++){
b[i][j]=0;
//cout<<a[i][j]<<" ";
for(int k=1;k<=c;k++){
b[i][j]+=(a[i][k]*a[k][j])%MOD;
b[i][j]%=MOD;
}
}
// cout<<endl;
}
swap(b,a);
}
return ;
}
int main(){
cin>>r>>c>>q;
for(int i=1;i<=c;i++){
a[i][i-1]=1;
a[i][i]=1;
a[i][i+1]=1;
res[i][i]=1;
}
P(r-1);
for(int i=1;i<=q;i++){
char c;
ll x,y;
cin>>c>>x>>y;
ll a1=0;
ll b1=0;
cout<<r-1<<" "<<res[x][y]<<endl;
}
return 0;
}
/*
3 1
1 2
2 3
3 1 1 2
*/
Compilation message
chessrush.cpp: In function 'int main()':
chessrush.cpp:77:12: warning: unused variable 'a1' [-Wunused-variable]
77 | ll a1=0;
| ^~
chessrush.cpp:78:12: warning: unused variable 'b1' [-Wunused-variable]
78 | ll b1=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |