1 条题解

  • 0
    @ 2025-12-11 10:21:05
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr);
    	
    	int n;
    	cin >> n;
    	vector<vector<int>> a(n, vector<int>(n));
    	
    	for (int i = 0; i < n; i++)
    		for (int j = 0; j < n; j++)
    			cin >> a[i][j];
    	
    	int q;
    	cin >> q;
    	
    	while (q--) {
    		char op;
    		cin >> op;
    		
    		if (op == 'R') {
    			int r, x;
    			cin >> r >> x;
    			for (int j = 0; j < n; j++)
    				a[r][j] += x;
    		} 
    		else if (op == 'C') {
    			int c, x;
    			cin >> c >> x;
    			for (int i = 0; i < n; i++)
    				a[i][c] += x;
    		} 
    		else if (op == 'D') {
    			int x;
    			cin >> x;
    			for (int i = 0; i < n; i++)
    				a[i][i] += x;
    		} 
    		else if (op == 'A') {
    			int x;
    			cin >> x;
    			for (int i = 0; i < n; i++)
    				a[i][n - 1 - i] += x;
    		}
    	}
    	
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			cout << a[i][j];
    			if (j + 1 < n) cout << " ";
    		}
    		cout << "\n";
    	}
    	return 0;
    }
    
    
    • 1

    信息

    ID
    142
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    (无)
    递交数
    1
    已通过
    1
    上传者