QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621523#9422. Two-star ContestzhoudashuaiWA 0ms3612kbC++142.4kb2024-10-08 15:07:132024-10-08 15:07:27

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 15:07:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-08 15:07:13]
  • 提交

answer

#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set> 
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#include<cassert>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define ep emplace_back 
#define debug(x) cout<<x<<'\n'
#define RES cout<<res<<'\n'
#define ANS cout<<ans<<'\n'
#define YES	cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes	cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define r23 cout<<233<<endl;return;
#define int long long 
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
typedef unsigned long long ull;
const int N=4e5+5,P=131,mod=998244353;

int n,m,k; 
struct node{
	int s,sum,cnt,id;
};
bool cmp(node a,node b){
	if(a.s==b.s)return a.sum<b.sum;
	return a.s<b.s;
}
void solve(){
	cin>>n>>m>>k;
	int f=1;
	struct node a[n+3];
	int g[m+3][m+3];
	L(i,1,n){
		cin>>a[i].s;
		int sum=0,cnt=0;
		L(j,1,m){
			cin>>g[i][j];
			if(g[i][j]==-1)cnt++;
			else sum+=g[i][j];
		}
		a[i].sum=sum,a[i].id=i,a[i].cnt=cnt;
	}
	sort(a+1,a+1+n,cmp);
	int ma=a[1].sum;
	int pre=-1;
	L(i,1,m){
		if(g[a[1].id][i]==-1)g[a[1].id][i]=0;
	}
	L(i,2,n){
		if(a[i].s==a[i-1].s){
			ma=max(ma,a[i].sum);
			if(a[i].sum>pre){
				L(j,1,m){
					if(g[a[i].id][j]==-1)g[a[i].id][j]=0;
				}
			}else{
				int nd=pre-a[i].sum+1;
				if(a[i].cnt*k<nd){
					f=0;break;
				} else{
					L(j,1,m){
						if(g[a[i].id][j]==-1){
							g[a[i].id][j]=min(nd,k);nd-=k;
							if(nd<=0)nd=0;
						}
					}
				}
			}
		}else{
			pre=ma;
			if(a[i].sum>pre){
				ma=a[i].sum;
				L(j,1,m){
					if(g[a[i].id][j]==-1)g[a[i].id][j]=0;
				}
			}else{
				int nd=pre-a[i].sum+1;
				if(a[i].cnt*k<nd){
					f=0;break;
				} else{
					L(j,1,m){
						if(g[a[i].id][j]==-1){
							g[a[i].id][j]=min(nd,k);nd-=k;
							if(nd<=0)nd=0;
						}
					}
				}
				ma=ma+1;
			}
		}
	}
	if(!f){
		NO;
	}else{
		YES;
		L(i,1,n){
			L(j,1,m){
				cout<<g[i][j]<<' ';
			}cout<<endl;
		}
	}
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T=1;
	cin>>T;
	while(T--){
		solve();
	}
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

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 "YES", doesn't correspond to pattern "Yes|No" (test case 1)