제출 #641711

#제출 시각아이디문제언어결과실행 시간메모리
641711Vladth11Chess Rush (CEOI20_chessrush)C++14
13 / 100
47 ms16632 KiB
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <int, int> pii; const int NMAX = 100001; const int VMAX = 101; const int INF = 2e9; const int MOD = 1000000007; const int BLOCK = 447; const int base = 117; const int nr_of_bits = 24; const int inv2 = 500000004; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; int R, C; bool OK(int i, int j){ if(i < 1 || j < 1 || i > R || j > C) return 0; return 1; } void add(int &x, int val){ x = (1LL * x + 1LL * val) % MOD; } pii cnt[101][101][101]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q; cin >> R >> C >> q; for(int i = 1; i <= C; i++){ queue <pii> q; q.push({1, i}); cnt[i][1][i] = {0, 1}; while(q.size()){ pii x = q.front(); q.pop(); for(int d = 0; d < 8; d++){ int ni = x.first + dx[d]; int nj = x.second + dy[d]; if(!OK(ni, nj)) continue; if(cnt[i][ni][nj].second == 0){ q.push({ni, nj}); cnt[i][ni][nj] = cnt[i][x.first][x.second]; add(cnt[i][ni][nj].first, 1); }else if(cnt[i][ni][nj].first == cnt[i][x.first][x.second].first + 1){ add(cnt[i][ni][nj].second, cnt[i][x.first][x.second].second); } } } } while(q--) { int c1, cR; char T; cin >> T; cin >> c1 >> cR; cout << cnt[c1][R][cR].first << " " << cnt[c1][R][cR].second << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...