QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626377#9422. Two-star ContestedhliiWA 29ms4404kbC++141.7kb2024-10-10 07:23:422024-10-10 07:23:43

Judging History

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

  • [2024-10-10 07:23:43]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:4404kb
  • [2024-10-10 07:23:42]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

int testCase;

struct star {
	int val, pos;
	ll sum = 0;
};
bool cmp(const star &a, const star &b) {
	if (a.val == b.val) return a.sum < b.sum;
	return a.val < b.val;
}

void process() {
	int n, m;
	ll k;
	ll preSum = 0;
	cin >> n >> m;
	cin >> k;
	vector<star> s(n);
	vector<vector<ll> > p(n, vector<ll>(m));
	for (int i = 0; i < n; i++) {
		cin >> s[i].val;
		s[i].pos = i;
		for (int j = 0; j < m; j++) {
			cin >> p[i][j];
			if (p[i][j] != -1) s[i].sum += p[i][j];
		}
	}
	sort(s.begin(), s.end(), cmp);
	for (int e = 0; e < n; e++) {
		int i = s[e].pos;
		// cout << s[e].val << " " << s[e].pos << " \n";
		if (e == 0) {
			for (int j = 0; j < m; j++) {
				if (p[i][j] == -1) p[i][j] = 0;
			}
			preSum = s[e].sum;
			// cout << preSum << " \n";
			continue;
		}
		ll needingSum = max(preSum + 1 - s[e].sum, 0LL);
		// cout<<needingSum<<" ";
		for (int j = 0; j < m; j++) {
			if (p[i][j] == -1) {
				p[i][j] = min(k, needingSum);
				needingSum -= k;
				s[e].sum += p[i][j];
			}
			needingSum = max(needingSum, 0LL);
		}
		if (needingSum > 0) {
			cout << "No\n"; return;
		}
		preSum = s[e].sum;
		// cout << preSum << " ";
	}
	cout << "Yes\n";
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) cout << p[i][j] << " ";
		cout << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("a.inp", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	cin >> testCase;
	while (testCase--) process();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

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: 29ms
memory: 4404kb

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)