QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#520219#6389. TopicalZhoumoruen12 79ms137880kbC++142.3kb2024-08-15 11:45:152024-08-15 11:45:15

Judging History

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

  • [2024-08-15 11:45:15]
  • 评测
  • 测评结果:12
  • 用时:79ms
  • 内存:137880kb
  • [2024-08-15 11:45:15]
  • 提交

answer

/*
    * @file T3.cpp
    * @author Zhoumouren
    * @brief 
    * @version 0.1
    * @date 2024-08-15
    * 
    * @copyright Copyright (c) 2024

Easy.
We can count the number of theme then use queue like BFS to Solve it.

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int long long 

namespace FastOI 
{
    template<typename T> inline T read(T& x) {
        x = 0;
        int f = 1;
        char ch;
        while (!isdigit(ch = getchar())) if (ch == '-') f = -1;
        while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
        x *= f;
        return x;
    }
    template<typename T, typename... Args> inline void read(T& x, Args &...x_) {
        read(x);
        read(x_...);
        return;
    }
    inline ll read() {
        ll x;
        read(x);
        return x;
    }
    inline void read(char *s) {
        scanf("%s", s + 1);
    }
};
using namespace FastOI;

const int N = 1e6 + 10;

int n, k;
vector<int >r[N];
vector<int >u[N];

vector<int >v[N];
int can[N];
int cnt[N], nowc[N];
queue<int >q;

void Input() {
    read(n, k);
    for(int i = 1; i <= n; i++) {
        r[i].push_back(0);
        for(int j = 1; j <= k; j++) {
            r[i].push_back(read());
            if(r[i][j] == 0) {
                can[i]++;
                cnt[j]++;
                v[j].push_back(i);
            }
        }
        if(can[i] == k) q.push(i);
    }
    for(int i = 1; i <= n; i++) {
        u[i].push_back(0);
        for(int j = 1; j <= k; j++) {
            u[i].push_back(read());
        }
    }
}

void Work() {
    for(int j = 1; j <= k; j++) {
        sort(v[j].begin(), v[j].end(), [&](int x, int y) {
            return r[x][j] < r[y][j];
        });
    }
    int ans = q.size();
    while(!q.empty()) {
        int f = q.front(); q.pop();
        for(int i = 1; i <= k; i++) {
            nowc[i] += u[f][i];
            while(cnt[i] < n && r[v[i][cnt[i]]][i] <= nowc[i]){
                int x = v[i][cnt[i]++];
                can[x]++;
                if(can[x] == k) {
                    q.push(x);
                    ans++;
                }
            }
        }
    }
    printf("%lld", ans);
}

signed main() {
    int T = 1;
    while(T--) {
        Input();
        Work();
    }
    return 0;
}

詳細信息

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 12ms
memory: 74924kb

input:

1 1
693647287
340782526

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 12
Accepted
time: 10ms
memory: 79464kb

input:

1 100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
279985824 991797187 998715443 98505529 106002744 636773096 815089164 196160830 796988849 87975...

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 12
Accepted
time: 4ms
memory: 79684kb

input:

1 10000
841961872 0 0 0 0 0 0 0 0 0 0 0 0 0 831386430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 205210920 705123207 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 276768098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 661649446 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 12
Accepted
time: 79ms
memory: 137800kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 12
Accepted
time: 67ms
memory: 137880kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 12
Accepted
time: 53ms
memory: 137740kb

input:

1 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 12
Accepted
time: 15ms
memory: 96572kb

input:

1 1000000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...

output:

0

result:

ok 1 number(s): "0"

Subtask #2:

score: 0
Runtime Error

Test #8:

score: 0
Runtime Error

input:

100 1
893339036
896783899
690308537
201770764
262364362
105000893
770698921
744238454
470980016
935046317
642998516
100481910
392307650
116783134
196939768
372329082
346372520
43063564
245523488
389084350
130314590
412588681
987795927
681635353
304582580
472268968
700147283
743357606
792644412
99955...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #15:

score: 0
Runtime Error

input:

10000 1
568857328
651788426
751475430
102940442
763289419
468657944
770847628
780257867
16919385
575963868
281824241
291248174
140016533
313529232
302186452
32709864
787073783
1926820
239509174
220454071
34252400
390385721
675239026
245106357
489697460
28435096
825528061
159083009
16370561
223299279...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%