Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
377512 许安哲 [ 2016年绍兴市第十四届少儿信息学竞赛复赛 ] - 辣椒炸弹 C++ 编译错误 0 0 MS 0 KB 1035 2026-02-01 11:19:26

Tests(0/0):


#include <iostream> #include <vector> #include <algorithm> using namespace std; struct RowInfo { int a; int b; bool operator<(const RowInfo& other) const { if (b != other.b) { return b > other.b; } return a < other.a; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int c, d, e, f; cin >> c >> d >> e >> f; vector<RowInfo> g(c + 1); for (int i = 1; i <= c; ++i) { g[i].a = i; g[i].b = 0; } for (int i = 0; i < f; ++i) { int h, i; cin >> h >> i; g[h].b++; } sort(g.begin() + 1, g.end()); int j = 0; vector<int> k; for (int i = 1; i <= e; ++i) { j += g[i].b; k.push_back(g[i].a); } sort(k.begin(), k.end()); cout << j << '\n'; for (size_t i = 0; i < k.size(); ++i) { if (i > 0) { cout << ' '; } cout << k[i]; } cout << '\n'; return 0; }


测评信息: