QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695884#9422. Two-star ContestMoemi_WA 24ms4392kbC++203.4kb2024-10-31 20:59:262024-10-31 21:00:11

Judging History

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

  • [2024-10-31 21:00:11]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:4392kb
  • [2024-10-31 20:59:26]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <numeric>

#define sc_int(x) scanf("%d", &x)

#define x first
#define y second
#define pb push_back

using namespace std;

const int N = 1e6 + 10, M = 5010, MOD = 998244353;
const int inf = 1e9;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef pair<char, int> PCI;
typedef pair<string, string> PSS;

LL n, m, k;

struct p
{
    LL s, cnt, sum, num;
    vector<int> t;
    bool operator< (const p &p) const
    {
        return s < p.s;
    }
};

void solve() 
{
    cin >> n >> m >> k;
    vector<p> a(n);
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i].s;
        a[i].num = i;
        vector<int> t;
        for(int j = 0; j < m; j ++)
        {
            int x;
            cin >> x;
            t.pb(x);
            if(~x) a[i].sum += x;
            else a[i].cnt ++;
        }
        a[i].t = t;
    }

    sort(a.begin(), a.end());
    // for(int i = 0; i < n; i ++) cout << a[i].num << " ";
    // cout << endl;
    LL pre = 0, mx1 = 0, mx2 = 0;
    vector<vector<int>> res(n);
    for(int i = 0; i < n; i ++)
    {
        auto [s, cnt, sum, num, g] = a[i];
        // cout << s << " " << endl;
        if(s == pre)
        {
            if(sum > mx2)
            {
                while(cnt -- ) res[i].pb(0);
                mx1 = max(mx1, sum);
            }
            else 
            {
                if(cnt * k + sum <= mx2)
                {
                    cout << "No" << endl;
                    return;
                }
                for(int j = 0; j < (mx2 - sum) / k; j ++) res[i].pb(k), cnt --;
                res[i].pb((mx2 - sum) % k + 1), cnt --;
                while(cnt --) res[i].pb(0);
                mx1 = max(mx1, mx2 + 1);
            }
        }
        else 
        {
            if(sum > mx1)
            {
                while(cnt --) res[i].pb(0);
                mx2 = mx1, mx1 = sum;
            }
            else
            {
                if(cnt * k + sum <= mx1)
                {
                    cout << "No" << endl;
                    return;
                }
                for(int j = 0; j < (mx1 - sum) / k; j ++) res[i].pb(k), cnt --;
                res[i].pb((mx1 - sum) % k + 1), cnt --;
                while(cnt --) res[i].pb(0);
                mx2 = mx1, mx1 ++;
            }
        }
        // cout << pre << " " << mx1 << " " << mx2 << endl;
        pre = s;
    }

    map<int, int> mp;
    for(int i = 0; i < n; i ++) mp[a[i].num] = i;

    cout << "Yes" << endl;
    for(int t = 0; t < n; t ++)
    {
        int i = mp[t];
        int idx = 0;
        for(int j = 0; j < m; j ++) 
        {
            if(a[i].t[j]  != -1) cout << a[i].t[j]  << " ";
            else
            {
                cout << res[i][idx ++] << " ";
            }
        }
        cout << endl;
    }
}

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int T = 1;
    cin >> T;
    while(T --)
    {
        solve();
    }
}

详细

Test #1:

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

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: 24ms
memory: 4392kb

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 ...

result:

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