QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#631783#9422. Two-star Contestretired_midlightsWA 29ms5792kbC++142.1kb2024-10-12 10:15:442024-10-12 10:15:46

Judging History

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

  • [2024-10-12 10:15:46]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:5792kb
  • [2024-10-12 10:15:44]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (int)a; i <= (int)b; i ++)
#define per(i, a, b) for(int i = (int)a; i >= (int)b; i --)
#define ll long long
using namespace std;
const int maxn = 400010;
int id[maxn], s[maxn];
bool cmp(int x, int y) { return s[x] < s[y]; }
void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector < vector < int > > p(n + 5, vector < int > (m + 5));
    rep(i, 1, n) {
        cin >> s[i];
        rep(j, 1, m) cin >> p[i][j];
        id[i] = i;
    }
    id[n + 1] = 0;
    sort(id + 1, id + 1 + n, cmp);
    vector < pair < int, int > > lines;
    int l = 1, r = 1;
    rep(i, 2, n + 1) {
        if(s[id[i]] == s[id[i - 1]]) r ++;
        else {
            lines.emplace_back(l, r);
            l = r + 1, r ++;
        }
    }
    ll mx = 0;
    // rep(i, 1, n) cout << id[i] << " \n";
    for(auto [x, y] : lines) {
        // cerr << "x : " << x << " y : " << y << " mx : " << mx << endl;
        rep(i, x, y) {
            ll sum = 0;
            rep(j, 1, m) {
                if(p[id[i]][j] != -1) sum += p[id[i]][j];
            }
            if(sum <= mx) {
                ll needs = mx - sum + 1;
                rep(j, 1, m) {
                    if(p[id[i]][j] == -1) {
                        p[id[i]][j] = min(1ll * k, needs);
                        needs -= min(1ll * k, needs);
                    }
                }
                if(needs > 0) {
                    cout << "No\n";
                    return;
                }
            } else {
                rep(j, 1, m) if(p[id[i]][j] == -1) p[id[i]][j] = 0;
            }
        }
        rep(i, x, y) {
            ll sum = 0;
            rep(j, 1, m) sum += p[id[i]][j];
            mx = max(mx, sum);
        }
    }
    cout << "Yes\n";
    rep(i, 1, n) rep(j, 1, m) cout << p[i][j] << " \n"[j == m];
}
int main() {
#ifdef LOCAL
    freopen("data.in", "r", stdin);
#endif
    ios :: sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T --) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5644kb

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
2 0 0
1 0 0

result:

ok ok 5 cases (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 5792kb

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:

No
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 975402536 248560376 0 0 0
9754...

result:

wrong answer Participant fails to find an answer while the jury found one. (test case 1)