全部评论 5

  • 我和你一样是RE

    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std; 
    int main() {
    long long  n, m;
    cin >> n >> m;
    vector<vector<int>> balls(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
    cin >> balls[i][j];
    }
    }
    vector<pair<int, int>> moves; 
    
    for (int color = 0; color < m; color++) {
    vector<pair<int, int>> count; 
    for (int i = 0; i <= n; i++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
    if (balls[i][j] == color) {
    cnt++;
    }
    }
    count.push_back({cnt, i});
    } 
        sort(count.begin(), count.end()); 
        
        for (int i = 0; i < n; i++) {
            if (count[i].first == 0) break;
            long long from = count[i].second;
            long long to = count[n].second;
            moves.push_back({from + 1, to + 1}); 
            balls[to][count[n].first - 1] = balls[from][count[i].first - 1];
            balls[from][count[i].first - 1] = 0; 
        }
    }
    cout << moves.size() << endl;
    for (auto move : moves) {
        cout << move.first << " " << move.second << endl;
    }
    return 0;
    }
    

    6啊

    2024-07-25 来自 浙江

    0
  • xiexie

    2024-05-19 来自 广东

    0
  • running error 数组越界,除以0 或空容器删除元素

    2024-05-19 来自 上海

    0
  • RE是数组开小了

    2024-05-19 来自 河南

    0
  • https://www.acgo.cn/discuss/15365(作者:AC)

    2024-05-18 来自 上海

    0
首页