QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#719376#9422. Two-star ContestSilverGodlyTL 0ms0kbC++232.4kb2024-11-07 00:28:142024-11-07 00:28:15

Judging History

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

  • [2024-11-07 00:28:15]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-07 00:28:14]
  • 提交

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 = -1;
    for(int i = 1;i<=n;i++){
        auto [x,id] = s[i];
        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(mx <= lst){
            cout << "No" << endl;
            return;
        }
        int d = 0;
        if(mn < lst + 1){
            d = lst - mn + 1;
        }
        lst = d + sum;
        for(int j = 1;j<=m;j++){
            if(p[id][j] == -1){
                p[id][j] = min({d,k});
                d -= min({d,k});
            }
        }
    }
    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;
    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] << " ";
        }
        cout << endl;
    }
    
    return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    if (t == 5){
        while(t--)solve1();
    }
    int cnt = 0;
    while (t--)solve(++cnt);
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

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 




















94271103018576 0 0 0 
94271103018576 0 0 0 



































































































































































...

result: