C Corrupted Contest
有两种唯一的情况
1.所有的人都没过题,即全为0
2.每一种过题的情况,榜单都包含。即过题情况为m从到1,或从m到0;
代码如下
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; b >>= 1; a *= a; } return ans; }
ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
const int mod=1e9+7;
const int N=1e5+7;
int score[N];//储存榜单
vector<int>s; //储存排名
int main(){
int n,m;
while(cin>>n>>m){
for(int i=1;i<=n;i++){
cin>>score[i];
}
if(score[1]==0) { //当所有人都是0的情况
while(n--)
cout<<"0"<<endl;
return 0;
}
s.clear();
s.push_back(m); //由得分的首到尾依次构造过题数
for(int i=2;i<=n;i++){
if(score[i]<score[i-1]) {
s.push_back(--m);
}
else s.push_back(m);
}
//两种情况 不唯一
//最后一名罚时为0,而过题数不为0
//最后一面罚时不为0,而过题数不为1
if((s[s.size()-1]!=0&&score[n-1]==0)||(s[s.size()-1]!=1&&score[n-1]!=0)) cout<<"ambiguous"<<endl;
else for(int i=0;i<s.size();i++) cout<<s[i]<<endl;
}
return 0;
}
京公网安备 11010502036488号