QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749100 | #9422. Two-star Contest | Yuu# | WA | 0ms | 3620kb | C++23 | 3.2kb | 2024-11-14 22:39:18 | 2024-11-14 22:39:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
// The 2024 ICPC Kunming Invitational Contest
void sol(){
int n, m, k;
std::cin>>n>>m>>k;
std::vector V(n + 1, std::vector<int>(m + 1));
std::vector info(n + 1, std::array<int, 4>{0, 0, 0, 0});
for(int i = 1; i <= n;i++){
std::cin>>info[i][0];
info[i][3] = i;
for(int j = 1;j <= m;j++){
std::cin>>V[i][j];
if(V[i][j] == -1) {
info[i][2] += 1;
}else{
info[i][1] += V[i][j];
}
}
}
std::sort(info.begin(), info.end());
std::vector<int>vi(n + 1, -1);
for(int i = 1;i <= n;i++){
int j = i, cV = -1, Mn = 0;
while(j <= n && info[j][0] == info[i][0]){
Mn = std::max(Mn, info[i][1]);
if(info[i][2] == 0){
if(cV == -1){
cV = info[i][1];
if(cV <= vi[i - 1]) {
std::cout<<"NO\n";
return ;
}
}else{
if(cV != info[i][1]){
std::cout<<"NO\n";
return ;
}
}
}
j++;
}
Mn = std::max(Mn, vi[i - 1] + 1);
// 确保cV > vi[i - 1]
if(cV == -1){
// 取Mn为s[i]的最小值.
for(int u = i;u < j;u++){
vi[u] = Mn;
if(info[u][1] + info[u][2] * k < Mn){
std::cout<<"NO\n";
return ;
}
int cur = info[u][1], ii = info[u][3];
for(int v = 1;v <= m;v++){
if(V[ii][v] == -1){
if(Mn - cur >= k){
cur = cur + k;
V[ii][v] = k;
}else{
V[ii][v] = Mn - cur;
cur = Mn;
}
}
}
}
}else{
if(Mn > cV){
std::cout<<"NO\n";
return ;
}
for(int u = i;u < j;u++){
vi[u] = cV;
if(info[u][1] + info[u][2] * k < cV){
std::cout<<"NO\n";
return ;
}
int cur = info[u][1], ii = info[u][3];
for(int v = 1;v <= m;v++){
if(V[ii][v] == -1){
if(cV - cur >= k){
V[ii][v] = k;
cur = cur + k;
}else{
V[ii][v] = cV - cur;
cur = cV;
}
}
}
}
}
i = j - 1;
}
std::cout<<"Yes\n";
for(int i = 1;i<=n;i++){
for(int j = 1;j <= m;j++){
std::cout<<V[i][j]<<" \n"[j == m];
}
}
}
signed main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1; std::cin>>t;
while(t--) sol();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
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:
wrong answer Token parameter [name=yesno] equals to "NO", doesn't correspond to pattern "Yes|No" (test case 2)