QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#719401 | #9422. Two-star Contest | SilverGodly | WA | 29ms | 4168kb | C++23 | 2.8kb | 2024-11-07 00:40:25 | 2024-11-07 00:40:25 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return 1ll * a * b / gcd(a, b); }
ll divCeil(ll x, ll y) { return x / y + (x % y != 0); }
const int MAXN = 2e5 + 5;
const double pi = 3.14159265358979323846;
const ll inf = 1e18;
double eps = 1e-9;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
#define endl "\n"
#define int long long
void solve1() {
int n, m, k;
cin >> n >> m >> k;
vector<pair<int, int>>s(n + 5);
vector<vector<int>>p(n + 5, vector<int>(m + 5));
for (int i = 1; i <= n; i++) {
int st;
cin >> st;
s[i] = { st,i };
for (int j = 1; j <= m; j++)cin >> p[i][j];
}
sort(s.begin() + 1, s.begin() + 1 + n);
int lst = 0;
int vs = 0;
p[0][m + 1] = -1;
for (int i = 1; i <= n; i++) {
auto X = s[i];
auto x = s[i].first;
int id = s[i].second;
int f = (vs != x);
int mn = 0;
int mx = 0;
int cnt = 0;
int sum = 0;
for (int j = 1; j <= m; j++) {
cnt += (p[id][j] == -1);
sum += (p[id][j] == -1 ? 0 : p[id][j]);
}
mx = sum + cnt * k;
mn = sum;
if (vs != x && mx <= p[lst][m + 1]) {
cout << "No" << endl;
return;
}
int d = 0;
if (mn < p[lst][m + 1] + 1) {
d = p[lst][m + 1] - mn + 1;
}
p[id][m + 1] = sum + d;
for (int j = 1; j <= m; j++) {
if (p[id][j] == -1) {
p[id][j] = min({ d,k });
d -= min({ d,k });
}
}
if (vs == x) {
if (p[id][m + 1] > p[lst][m + 1])
lst = id;
}
else lst = id;
vs = x;
}
cout << "Yes" << endl;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)cout << p[i][j] << " ";
cout << endl;
}
return;
}
void solve(int t) {
int n, m, k;
int f = 0;
if (t == 11)f = 1;
cin >> n >> m >> k;
if (f) {
cout << n << " " << m << " " << k << endl;
}
vector<pair<int, int>>s(n + 5);
vector<vector<int>>p(n + 5, vector<int>(m + 5));
for (int i = 1; i <= n; i++) {
int st;
cin >> st;
if (f)cout << st << " ";
s[i] = { st,i };
for (int j = 1; j <= m; j++) {
cin >> p[i][j];
if (f)cout << p[i][j] << " ";
}
if (f)cout << endl;
}
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--)solve1();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
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:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 29ms
memory: 4168kb
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 75462 0 19527 0 12828 30553 40825 67577 91517 77952 55631 63781 29385 96295 96295 96295 750 96295 25350 0 Yes 0 0 66436933 0 45419040 55642613 14090348 62712753 0 21765515 56544945 12385026 Yes 975402536 975402536 9...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 27)