QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623076#9422. Two-star Contestptit_noodlesWA 0ms9724kbC++141.9kb2024-10-09 10:00:152024-10-09 10:00:15

Judging History

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

  • [2024-10-09 10:00:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9724kb
  • [2024-10-09 10:00:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define ii pair<int, int>
const int N = 2e5+5, M = 1e3+5, inf = 1e18, MOD = 1e9+7;
int n, m, x, y, res, test, k, sum1, cnt;
int bc[N], sum[N];
//ii s[N];
vector<ii> ke[N];

struct node{
    int val, sum, id;
} s[N];

bool cmp(node a, node b) {
    if (a.val == b.val) return a.sum < b.sum;
    return a.val < b.val;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> test;
    while (test--) {
        cin >> n >> m >> k;
        int b[n + 1][m + 1];
        for (int i = 1; i <= n; ++i) {
            cin >> x; ke[i].clear();
            sum[i] = 0;
            for (int j = 1; j <= m; ++j) {
                cin >> b[i][j];
                if (b[i][j] == -1) ke[i].push_back({i, j});
                else sum[i] += b[i][j];
            }
            s[i] = {x, sum[i], i};
        }
        sort(s + 1, s + n + 1, cmp);
        int kt = 1;
        for (int i = 2; i <= n; ++i) {
            int j = -1;
            int id = s[i].id;
            while (sum[id] <= sum[s[i - 1].id]) {
                x = -sum[id] + sum[s[i - 1].id];
                y = sum[id];
                if (x >= k) sum[id] += k; else sum[id] += x;
                ++j;
                if (j >= ke[id].size() || !ke[id].size()) {
                    kt = 0;
                    break;
                }
                b[ke[id][j].first][ke[id][j].second] = sum[id] - y;
            }
            if (!kt) break;
        }
        if (!kt) cout << "No" << endl;
        else {
            cout << "Yes" << endl;
            for (int i = 1; i <= n; ++i){
                for (int j = 1; j <= m; ++j) {
                    cout << (b[i][j] == -1 ? 0 : b[i][j]) << ' ';
                }
                cout << endl;
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

No
No
Yes
1 2 3 
4 5 6 
No
No

result:

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