QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756668 | #9422. Two-star Contest | HaijieTan | WA | 27ms | 5660kb | C++23 | 2.8kb | 2024-11-16 21:29:39 | 2024-11-16 21:29:40 |
Judging History
answer
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<numeric>//iota -- iota(all(a), x) a从头到尾从x开始递增
#include<cstring>
#include<ctime>
#include<array>
#include<list>
#include<random>
#include<tuple>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define lowbit(x) (x & (-x))
const int xy[][2] = { 0,1, 0, -1, 1, 0, -1, 0 };
#define mem(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<char, char> PCC;
typedef pair<int, char> PIC;
typedef pair<char, int> PCI;
#define x first
#define y second
#define NO cout << "NO\n"
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define No cout << "No\n"
inline int read();
const int INF = 1e9, N = 1e4 + 10, MOD = 998244353, M = 1e4 + 10, K = 1331;
const double PI = acos(-1.0);
struct Node {
vector<int>a, vis;
};
void solve() {
int n, m, k; cin >> n >> m >> k;
vector<Node>g(n + 2);
vector<int>s(n + 2);
for (int i = 1; i <= n; i++) {
int sum = 0;
for (int j = 0; j <= m; j++) {
int x; cin >> x;
g[i].a.pb(x);
if (j)sum += max(0ll, x);
if (j && x == -1)g[i].vis.pb(j);
}
g[i].a.pb(sum);
s[i] = i;
}
auto cmp = [&](int x, int y) -> bool {
return g[x].a[0] > g[y].a[0];
};
sort(s.begin() + 1, s.begin() + 1 + n, cmp);
for (int t = 1; t <= n; t++) {
int i = s[t];
if (t == 1) {
for (auto j : g[i].vis)g[i].a[j] = k, g[i].a[m + 1] += k;
continue;
}
if (g[i].a[m + 1] >= g[s[t - 1]].a[m + 1])return No, void();
for (auto j : g[i].vis) {
if (g[i].a[m + 1] + k < g[s[t - 1]].a[m + 1]) {
g[i].a[m + 1] += k, g[i].a[j] = k;
}
else {
int p = g[s[t - 1]].a[m + 1] - g[i].a[m + 1] - 1;
g[i].a[m + 1] += p, g[i].a[j] = p;
break;
}
}
}
Yes;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)cout << max(g[i].a[j], 0ll) << " \n"[j == m];
}
signed main() {
IOS;
int _ = 1;
cin >> _;
while (_--)solve();
return 0;
}
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
/* /\_/\
* (= ._.)
* / > \>
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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 5 2 5 0 5 3 5 1 4 No Yes 1 2 3 4 5 6 No Yes 10000 10000 10000 10000 10000 9999
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 5660kb
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 No Yes 72716304 72716304 66436933 72716304 45419040 55642613 72716304 62712753 72716304 21765515 56544945 12385026 Yes 975402536 975402536 975402536 975402536 975402536 975402536 67482408 0 0 975402536 975402536 975402536 975402536 211610436 944794448 67558026 0 0 788675016 424172233...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 2)