QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610098#9407. Colorful Segments 2MiniLongAC ✓134ms8468kbC++172.9kb2024-10-04 14:55:082024-10-04 14:55:10

Judging History

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

  • [2024-10-04 14:55:10]
  • 评测
  • 测评结果:AC
  • 用时:134ms
  • 内存:8468kb
  • [2024-10-04 14:55:08]
  • 提交

answer

#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
    #ifdef ONLINE_JUDGE
    char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
    #define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
    #else
    #define get() getchar()
    #endif
    template<typename T> inline void read(T &t){
        T x = 0, f = 1;
        char c = getchar();
        while(!isdigit(c)){
            if(c == '-') f = -f;
            c = getchar();
        }
        while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
        t = x * f;
    }
    template<typename T, typename ... Args> inline void read(T &t, Args&... args){
        read(t);
        read(args...);
    }
    template<typename T> void write(T t){
        if(t < 0) putchar('-'), t = -t;
        if(t >= 10) write(t / 10);
        putchar(t % 10 + '0');
    }
    template<typename T, typename ... Args> void write(T t, Args... args){
        write(t), putchar(' '), write(args...);
    }
    template<typename T> void writeln(T t){
        write(t);
        puts("");
    }
    template<typename T> void writes(T t){
        write(t), putchar(' ');
    }
    #undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
    const ll mod = 998244353;
    ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
    void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
    void add(ll &x, ll y){x = (x + y) % mod;}
    void mul(ll &x, ll y){x = x * y % mod;}
    ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
    ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
    ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 5e5 + 5;
int n, k;
struct node{
    int l, r;
    bool operator<(const node b)const{
        return l == b.l ? r < b.r : l < b.l;
    }
}a[N];
int main(){
    multitest(){
        read(n, k);
        _rep(i, 1, n) read(a[i].l, a[i].r);
        sort(a + 1, a + 1 + n);
        priority_queue<int, vector<int>, greater<int> > q;
        ll ans = 1, cnt = 0;
        _rep(i, 1, n){
            while(q.size() && q.top() < a[i].l) q.pop(), cnt--;
            if(cnt >= k){ans = 0; break;}
            mul(ans, k - cnt);
            q.push(a[i].r), cnt++;
        }
        writeln(ans);
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3740kb

input:

2
4 3
4 7
3 4
5 8
1 3
2 1000
100 200
300 400

output:

24
1000000

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 70ms
memory: 8468kb

input:

6102
2 9
336470888 634074578
642802746 740396295
8 4
396628655 503722503
202647942 971207868
2087506 268792718
46761498 443917727
16843338 125908043
691952768 717268783
150414369 787375312
519096230 693319712
2 6
674936674 762263554
274667941 407246545
1 9
155191459 421436316
2 6
140515506 646837311...

output:

81
96
36
9
30
5760
0
0
729
0
10
0
288
65028096
0
240
0
96
120
1
512
0
604800
0
720
9
27216000
1
4032
0
24
169344
12960
0
0
810
25920
518400
0
4
0
0
16
240
0
3136
2
0
43200
213373440
24
0
4200
100
60
0
21600
172800
90000
1920
81
60000
537600
1210104
1
20
72
240
4
7560
20
480
70560
6
2352
21600
907200...

result:

ok 6102 lines

Test #3:

score: 0
Accepted
time: 122ms
memory: 8244kb

input:

1
500000 300000
54748096 641009859
75475634 804928248
284875072 476927808
503158867 627937890
322595515 786026685
645468307 669240390
588586447 939887597
521365644 973764525
710156469 985188306
11308832 860350786
770562147 784695957
35937909 208427221
67590963 726478310
255361535 475357775
135993561...

output:

546062331

result:

ok single line: '546062331'

Test #4:

score: 0
Accepted
time: 134ms
memory: 8136kb

input:

1
500000 1000000000
524125987 923264237
374288891 535590429
124321145 751244358
232930851 266089174
543529670 773363571
319728747 580543238
468188689 582720391
490702144 598813561
138628383 284660056
155605777 733781508
245485733 931759705
257812292 723534730
596788519 794937524
188451996 981010588
...

output:

740451561

result:

ok single line: '740451561'

Test #5:

score: 0
Accepted
time: 75ms
memory: 7416kb

input:

1
500000 702209411
3072531 3074746
778635780 778640277
438740609 438746788
134502233 134508220
501285916 501287582
335489419 335516765
210944433 210949131
777496408 777497662
971588225 971592046
877328396 877367423
379176532 379185365
473068553 473070614
711798608 711811582
80981555 80982252
3842913...

output:

249734118

result:

ok single line: '249734118'

Test #6:

score: 0
Accepted
time: 106ms
memory: 7600kb

input:

1
500000 585325539
907762921 907996797
524632690 525715282
811638499 811702024
716203557 717204436
907565805 907565805
323204236 323212851
304366504 304846599
367101896 367126091
401968507 402133204
576168921 576168921
275530644 276496387
346757480 346787325
403383668 403463167
301226069 301645829
6...

output:

38166575

result:

ok single line: '38166575'

Test #7:

score: 0
Accepted
time: 117ms
memory: 7584kb

input:

1
500000 58376259
173655389 178608705
950285264 958493791
227923588 231046739
361358884 361437210
605139702 606880594
989936548 996156451
180358494 187600244
876164101 876308310
364148670 369564811
650263198 656484404
857393213 879559387
680510347 680510347
669433889 686341268
939105066 976440053
86...

output:

329284601

result:

ok single line: '329284601'

Test #8:

score: 0
Accepted
time: 123ms
memory: 8236kb

input:

1
500000 941492387
178745080 432850480
347713857 455098515
759304764 991955922
43454383 196518815
493111893 869779131
480312139 771789569
233504946 239650385
1670964 166491132
886878825 976297546
551256124 551256124
744753935 870770575
53983958 106939130
466863009 628529697
648501839 942887280
33899...

output:

288269414

result:

ok single line: '288269414'

Extra Test:

score: 0
Extra Test Passed