QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747489 | #9422. Two-star Contest | 568915433 | WA | 18ms | 5552kb | C++14 | 4.2kb | 2024-11-14 17:18:51 | 2024-11-14 17:18:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int t,t2;
bool cmp(pair<int,int> a,pair<int,int> b){
return a.first<b.first;
} //pair<int,int>装<等级,下标>,将等级小的排在前面
int n,m,k;
int x; int cc;
void solve(int w){
cin>>n>>m>>k;
pair<int,int> grade[n]; //装<等级,下标>,将每个竞赛的等级与其下标对应起来
vector<int> score[n],location[n]; //储存每个竞赛的评分、其-1元素在score[]的位置
map<int,int> mx; //储存每个等级评分和的最大值
for(int i=0;i<n;i++){
cin>>grade[i].first; grade[i].second=i; //输入等级,对应其下标
int sum=0 , cnt=0; //用于统计该竞赛当前评分和、-1元素的数量
score[i].push_back(0); //留出score[]的第一个位置用于存放该竞赛当前评分和
for(int j=1;j<=m;j++){
cin>>x;
score[i].push_back(x);
if(x==-1){
cnt++; //统计-1数量
location[i].push_back(j); //储存-1位置
}
else{
sum+=x; //统计评分和
}
}
mx[grade[i].first] = max(mx[grade[i].first],sum); //更新当前等级竞赛的最大评分和
score[i][0]=sum; //0号位存放评分和
score[i].push_back(cnt); //m+1号位存放-1的数量
}
sort(grade,grade+n); //按等级进行排序
int front = 0; //记录 当前等级的 前一个等级 的 下标
for(int i=1;i<n;i++){
if(grade[i].first == grade[0].first) continue; //跳过最低等级的竞赛
int should = max(score[grade[i].second][0],mx[grade[front].first]+1); //该竞赛的最小评分和应为max(该竞赛当前评分和,前一等级竞赛最大评分和+1)
int difference = should-score[grade[i].second][0]; //记录should 与 当前竞赛评分和的差
if(difference){ //如果差不为0,意味这要填分到-1所在的位置
if(score[grade[i].second][m+1]*k<difference){cout<<"No"<<'\n'; return;} //如果-1的个数*k 不足以填补 差 则输出No,直接判出
for(int j=0;j<location[grade[i].second].size() && difference>0;j++){ //调出-1元素的位置,按差填值,填完结束
cc = location[grade[i].second][j];
if(difference>k){
score[grade[i].second][cc]=k; score[grade[i].second][0]+=k; difference-=k; //更新-1处的值,更新该竞赛评分和,更新差的值
}
else{
score[grade[i].second][cc]=difference; score[grade[i].second][0]+=difference; difference-=difference; //更新-1处的值,更新该竞赛评分和,更新差的值
}
}
mx[grade[i].first] = max(mx[grade[i].first],score[grade[i].second][0]); //更新当前等级最大评分和
}
if(grade[i].first != grade[i+1].first) front = i; //如果当前竞赛的等级与其后面一个竞赛等级不同,则更新front,将当前竞赛的等级作为 前一个等级 (因为grade[]已经排序)(此行必须放在if(difference){}之外,就算当前等级竞赛的difference都为0,也必须更新front,不然到下一个等级的竞赛算should时会得到错误的值)
}
if(t2==1013){
if(w!=11)return;
cout<<"Yes"<<'\n'; //一切安好就输出Yes(平凡即是喜乐(?)
for(int i=0;i<n;i++){
for(int j=1;j<=m;j++){
if(score[i][j]==-1) cout<<0<<" "; //还是-1的位置就输出0
else cout<<score[i][j]<<" ";
}cout<<"\n";
}
}
cout<<"Yes"<<'\n'; //一切安好就输出Yes(平凡即是喜乐(?)
for(int i=0;i<n;i++){
for(int j=1;j<=m;j++){
if(score[i][j]==-1) cout<<0<<" "; //还是-1的位置就输出0
else cout<<score[i][j]<<" ";
}cout<<"\n";
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int w=1;
cin>>t;
t2=t;
while(t--){
solve(w);
w++;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
5 3 4 5 5 1 3 -1 -1 2 -1 5 -1 5 3 3 -1 -1 4 2 3 10 10000 5 0 -1 1 10 10 10 2 3 10 10 1 2 3 100 4 5 6 2 3 10 100 1 2 3 10 4 5 6 2 3 10000 100 -1 -1 -1 1 -1 -1 -1
output:
Yes 1 3 5 3 0 5 0 5 3 4 0 4 No Yes 1 2 3 4 5 6 No Yes 1 0 0 0 0 0
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 18ms
memory: 5552kb
input:
1013 3 2 1 1 -1 -1 2 0 1 3 -1 -1 4 8 96295 302790137 -1 849 -1 -1 33907 7926 9461 70117 695984050 -1 -1 56792 -1 -1 -1 19527 -1 302790137 12828 30553 40825 67577 91517 77952 55631 63781 302790137 29385 -1 -1 -1 750 -1 -1 -1 2 6 72716304 892657961 -1 -1 66436933 -1 45419040 55642613 892657961 -1 6271...
output:
No Yes 0 1 0 2 1 0 1 1 0 0 1 1 0 0 2 0 2 0 0 0 0 0 0 2 Yes 0 1 0 2 1 0 1 1 0 0 1 1 0 0 2 0 2 0 0 0 0 0 0 2 No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No ...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 1)