3 条题解
-
0
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 2000 + 1; const int inf = 0x3f3f3f3f; int a[N][N]; bool zhou[N][N]; int n , m; int l = 1; int r = 0; int up = 1; int down = 0; void hqt(char x){ if(x == 'L'){ for(int i = up ; i <= n ; i ++){ a[i][l + 1] -= a[i][l]; zhou[i][l] = true; } l ++; }else if(x == 'R'){ for(int i = up ; i <= n ; i ++){ a[i][r - 1] -= a[i][r]; // if(a[i][r - 1] == -3){ // cout << "arg"; // } zhou[i][r] = true; } // cout << "aWEFT"; r --; }else if(x == 'U'){ for(int i = l ; i <= m ; i ++){ a[up + 1][i] -= a[up][i]; zhou[up][i] = true; } up ++; }else if(x == 'D'){ for(int i = l ; i <= m ; i ++){ a[down - 1][i] -= a[down][i]; zhou[down][i] = true; } down --; } } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("fold_sample4.in" , "r" , stdin); // freopen("1.ans" , "w" , stdout); cin >> n >> m; for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ cin >> a[i][j]; } } r = m; down = n; int step = n + m - 2; while(step --){ char t; cin >> t; hqt(t); // for(int i = 1 ; i <= n ; i ++){ // for(int j = 1 ; j <= m ; j ++){ // cout << a[i][j] << " "; // } // cout << endl; // } // cout << l << " " << r << " " << up << " " << down << endl; // cout << endl; } // for(int i = 1 ; i <= n ; i ++){ // for(int j = 1 ; j <= m ; j ++){ // cout << a[i][j] << " "; // } // cout << endl; // } // cout << endl; for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= m ; j ++){ // cout << zhou[i][j] << " "; if(!zhou[i][j]){ cout << a[i][j]; exit(0); } } // cout << endl; } return 0; }
信息
- ID
- 4445
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 29
- 已通过
- 6
- 上传者