5 solutions

  • 1
    @ 2025-3-30 14:42:16

    直接swap

    #include <bits/stdc++.h>
    #define endl '\n'
    using namespace std;
    typedef pair<int, int> PII;
    using ll = long long;
    using ULL = unsigned long long;
    const int N = 1e7 + 5;
    int n, m, a[10][10];
    inline void solve() {
        for (int i = 1; i <= 5; i++) 
            for (int j = 1; j <= 5; j++) 
                cin >> a[i][j];
        cin >> n >> m;
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 5; j++) {
                swap(a[n][j],a[m][j]);
            }
        }        
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 5; j++) {
                 cout << a[i][j] << ' ';
            }
            cout << endl;
        }    
    
    }
    int main() {
        ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int _ = 1;
        //int _; cin >> _;
        while (_--) solve();
        return 0;
    }
    
    

    Information

    ID
    86
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    4
    Tags
    # Submissions
    277
    Accepted
    125
    Uploaded By