QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#693662 | #9422. Two-star Contest | chenjue# | WA | 57ms | 4728kb | C++20 | 1.7kb | 2024-10-31 16:32:01 | 2024-10-31 16:32:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Node{
ll star;
ll id;
vector<ll> p;
ll sum;
bool operator<(const Node&a)const{
if(star != a.star) return star < a.star;
else{
return sum < a.sum;
}
}
};
bool cmp(Node a, Node b){
return a.id < b.id;
}
void slove(){
ll n, m, k; cin >> n >> m >> k;
Node a[n + 10];
for(int i = 1; i <= n; i++){
a[i].p.push_back(-2);
cin >> a[i].star;
a[i].sum = 0;
for(int j = 1; j <= m; j++){
ll x; cin >> x;
a[i].p.push_back(x);
a[i].id = i;
if(x != -1){
a[i].sum += x;
}
}
}
sort(a + 1, a + 1 + n);
//ll sum0 = 0;
bool ans = true;
pair<ll, ll> last;
a[0].star = a[1].star;
a[0].sum = -1;
for(int i = 1; i <= n; i++){
last = {a[i - 1].sum, a[i - 1].star};
//cout << last.first << "\n";
ll dsum = last.first - a[i].sum;
for(int j = 1; j <= m; j++){
if(a[i].p[j] == -1 && dsum == 0){
a[i].p[j] = 1;
a[i].sum += 1;
break;
}
if(a[i].p[j] == -1 && dsum > 0){
if(dsum < k){
a[i].p[j] = dsum + 1;
a[i].sum += dsum + 1;
dsum = 0;
break;
}
else{
a[i].p[j] = k;
a[i].sum += k;
dsum -= k;
}
}
}
if(a[i].sum <= last.first){
ans = false;
}
}
if(ans == false){
cout << "No\n";
return;
}
else{
cout << "Yes\n";
}
sort(a + 1, a + 1 + n, cmp);
for(int i = 1; i <= n; i ++){
for(auto x : a[i].p){
if(x == -2){
continue;
}
else if(x != -1){
cout << x << " ";
}
else{
cout << "0 ";
}
}
cout << "\n";
}
}
int main(){
int t; cin >> t;
while(t--){
slove();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
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: 57ms
memory: 4728kb
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:
Yes 0 0 0 1 1 1 Yes 0 849 0 0 33907 7926 9461 70117 96295 96295 56792 96295 75461 0 19527 0 12828 30553 40825 67577 91517 77952 55631 63781 29385 0 0 0 750 0 0 0 Yes 0 0 66436933 0 45419040 55642613 0 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 975402536 975402536 97540253...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 11)