Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
435175 王栎州 26年2月-A组(萌新)D. 限量销售 C++ 解答错误 0 25 MS 5148 KB 665 2026-04-04 14:02:21

Tests(0/10):


#include <iostream> using namespace std; int main() { int n, m,a[1000005],b[1000005]; cin >> n >> m; bool u[1000005] = {false}; int ans[1000005] = {0}; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } for (int i = n; i >= 1; i--) { bool o = false; if (!u[a[i]]) { u[a[i]] = true; o = true; } else if (!u[b[i]]) { u[b[i]] = true; o = true; } ans[i] = ans[i + 1] + o; } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } return 0; }


测评信息: