3 条题解

  • 0
    @ 2025-10-19 16:12:43
    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;
    }
    

    信息

    ID
    4445
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    (无)
    递交数
    29
    已通过
    6
    上传者