RE是什么
2024-05-18 21:28:24
发布于:广东
52阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50;
const int MAXM = 400;
int main() {
std::ios::sync_with_stdio(false);
int n,m;
cin >> n >> m;
vector<vector<int>> poles(n + 1, vector<int>(m));
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
cin >> poles[i][j];
}
}
vector<pair<int, int>> operations;
for (int color = 1; color <= n; ++color)
{
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (poles[i][j] == color)
{
operations.push_back({i + 1, n + 1});
}
else
{
operations.push_back({i + 1, 1});
}
}
}
for (int j = 0; j < m; ++j)
{
operations.push_back({n + 1, color});
}
}
cout << operations.size() << endl;
for (auto &op : operations)
{
cout << op.first << " " << op.second << endl;
}
return 0;
}
全部评论 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 来自 浙江
0xiexie
2024-05-19 来自 广东
0running error 数组越界,除以0 或空容器删除元素
2024-05-19 来自 上海
0RE是数组开小了
2024-05-19 来自 河南
0https://www.acgo.cn/discuss/15365(作者:AC)
2024-05-18 来自 上海
0
有帮助,赞一个