A11094 | Berland Elections
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The elections to Berland parliament are happening today. Voting is in full swing!
Totally there are $n$ candidates, they are numbered from $1$ to $n$ . Based on election results $k$ ( $1<=k<=n$ ) top candidates will take seats in the parliament.
After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table.
So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place).
There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than $k$ candidates will take a seat in the parliament.
In Berland there are $m$ citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of $n$ candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of $m$ citizens will vote for exactly one of $n$ candidates.
At the moment $a$ citizens have voted already ( $1<=a<=m$ ). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the $j$ -th citizen voted for the candidate $g_{j}$ . The citizens who already voted are numbered in chronological order; i.e. the $(j+1)$ -th citizen voted after the $j$ -th.
The remaining $m-a$ citizens will vote before the end of elections, each of them will vote for one of $n$ candidates.
Your task is to determine for each of $n$ candidates one of the three possible outcomes:
- a candidate will be elected to the parliament regardless of votes of the remaining $m-a$ citizens;
- a candidate has chance to be elected to the parliament after all $n$ citizens have voted;
- a candidate has no chances to be elected to the parliament regardless of votes of the remaining $m-a$ citizens.
Totally there are $n$ candidates, they are numbered from $1$ to $n$ . Based on election results $k$ ( $1<=k<=n$ ) top candidates will take seats in the parliament.
After the end of the voting the number of votes for each candidate is calculated. In the resulting table the candidates are ordered by the number of votes. In case of tie (equal number of votes) they are ordered by the time of the last vote given. The candidate with ealier last vote stands higher in the resulting table.
So in the resulting table candidates are sorted by the number of votes (more votes stand for the higher place) and if two candidates have equal number of votes they are sorted by the time of last vote (earlier last vote stands for the higher place).
There is no way for a candidate with zero votes to take a seat in the parliament. So it is possible that less than $k$ candidates will take a seat in the parliament.
In Berland there are $m$ citizens who can vote. Each of them will vote for some candidate. Each citizen will give a vote to exactly one of $n$ candidates. There is no option "against everyone" on the elections. It is not accepted to spoil bulletins or not to go to elections. So each of $m$ citizens will vote for exactly one of $n$ candidates.
At the moment $a$ citizens have voted already ( $1<=a<=m$ ). This is an open election, so for each citizen it is known the candidate for which the citizen has voted. Formally, the $j$ -th citizen voted for the candidate $g_{j}$ . The citizens who already voted are numbered in chronological order; i.e. the $(j+1)$ -th citizen voted after the $j$ -th.
The remaining $m-a$ citizens will vote before the end of elections, each of them will vote for one of $n$ candidates.
Your task is to determine for each of $n$ candidates one of the three possible outcomes:
- a candidate will be elected to the parliament regardless of votes of the remaining $m-a$ citizens;
- a candidate has chance to be elected to the parliament after all $n$ citizens have voted;
- a candidate has no chances to be elected to the parliament regardless of votes of the remaining $m-a$ citizens.
输入格式
The first line contains four integers $n$ , $k$ , $m$ and $a$ ( $1<=k<=n<=100$ , $1<=m<=100$ , $1<=a<=m$ ) — the number of candidates, the number of seats in the parliament, the number of Berland citizens and the number of citizens who already have voted.
The second line contains a sequence of $a$ integers $g_{1},g_{2},...,g_{a}$ ( $1<=g_{j}<=n$ ), where $g_{j}$ is the candidate for which the $j$ -th citizen has voted. Citizens who already voted are numbered in increasing order of voting times.
The second line contains a sequence of $a$ integers $g_{1},g_{2},...,g_{a}$ ( $1<=g_{j}<=n$ ), where $g_{j}$ is the candidate for which the $j$ -th citizen has voted. Citizens who already voted are numbered in increasing order of voting times.
输出格式
Print the sequence consisting of $n$ integers $r_{1},r_{2},...,r_{n}$ where:
- $r_{i}=1$ means that the $i$ -th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining $m-a$ citizens;
- $r_{i}=2$ means that the $i$ -th candidate has a chance to take a seat in the parliament, i.e. the remaining $m-a$ citizens can vote in such a way that the candidate will take a seat in the parliament;
- $r_{i}=3$ means that the $i$ -th candidate will not take a seat in the parliament regardless of votes of the remaining $m-a$ citizens.
- $r_{i}=1$ means that the $i$ -th candidate is guaranteed to take seat in the parliament regardless of votes of the remaining $m-a$ citizens;
- $r_{i}=2$ means that the $i$ -th candidate has a chance to take a seat in the parliament, i.e. the remaining $m-a$ citizens can vote in such a way that the candidate will take a seat in the parliament;
- $r_{i}=3$ means that the $i$ -th candidate will not take a seat in the parliament regardless of votes of the remaining $m-a$ citizens.
输入输出样例
输入 #1
3 1 5 4 1 2 1 3
输出 #1
1 3 3
输入 #2
3 1 5 3 1 3 1
输出 #2
2 3 2
输入 #3
3 2 5 3 1 3 1
输出 #3
1 2 2
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted