3 条题解
-
0
using namespace std; int a[2010][2010]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("fold_sample1.in","r",stdin); int n, m; cin >> n >> m; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ cin >> a[i][j]; } } string v; cin >> v; int n1 = 1, m1 = 1, n2 = n, m2 = m; for(int i = 0; i < v.size(); i ++){ if(v[i] == 'L'){ for(int j = n1; j <= n2; j ++){ a[j][m1 + 1] -= a[j][m1]; } m1 ++; } else if(v[i] == 'R'){ for(int j = n1; j <= n2; j ++){ a[j][m2 - 1] -= a[j][m2]; } m2 --; } else if(v[i] == 'U'){ for(int k = m1; k <= m2; k ++){ a[n1 + 1][k] -= a[n1][k]; } n1 ++; } else{ for(int k = m1; k <= m2; k ++){ a[n2 - 1][k] -= a[n2][k]; } n2 --; } } cout << a[n1][m1]; return 0; } -
0
#include using namespace std; long long n,m,a[2020][2020],l,a1=1,a2,a3=1,a4; char b[40000]; //bool z(long long a,long long b){ // return a>b; //} int main(){ // freopen("fold_sample2.in","r",stdin); ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n>>m; a2=m,a4=n; for(long long i=1;i<=n;i++){ for(long long j=1;j<=m;j++){ cin>>a[i][j]; } } cin>>b; l=n+m-2; for(long long z=0;z<l;z++){ if(b[z]=='L'){ for(long long i=a3;i<=a4;i++){ a[i][a1+1]-=a[i][a1]; } a1++; } else if(b[z]=='R'){ for(long long i=a3;i<=a4;i++){ a[i][a2-1]-=a[i][a2]; } a2--; } else if(b[z]=='U'){ for(long long i=a1;i<=a2;i++){ a[a3+1][i]-=a[a3][i]; } a3++; } else{ for(long long i=a1;i<=a2;i++){ a[a4-1][i]-=a[a4][i]; } a4--; } // cout<<a1<<' '<<a2<<' '<<a3<<' '<<a4<<"\n"; // for(long long i=a1;i<=a4;i++){ // for(long long j=a3;j<=a2;j++){ // cout<<a[i][j]<<' '; // } // cout<<"\n"; // } } cout<<a[a3][a1]; return 0; } -
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; }
- 1
信息
- ID
- 4445
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 29
- 已通过
- 6
- 上传者