結果

問題 No.2197 Same Dish
ユーザー lddlinanlddlinan
提出日時 2023-03-14 15:58:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,116 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 87,568 KB
実行使用メモリ 4,840 KB
最終ジャッジ日時 2023-10-18 11:45:51
合計ジャッジ時間 2,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 8 ms
4,348 KB
testcase_14 AC 42 ms
4,656 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 48 ms
4,840 KB
testcase_20 WA -
testcase_21 AC 45 ms
4,840 KB
testcase_22 AC 47 ms
4,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;



typedef struct { int i, k; } RNode;
RNode rs[200004];
bool mycmp(const RNode& a, const RNode& b) {
    if (a.i!=b.i) return a.i<b.i;
    return a.k<b.k;
}
#define MOD 998244353

int main() {
    int n, i, k, ck, s, e, j, nj, d, cc, c;
    LL b, r, bb, v, t;
    scanf("%d %d", &n, &k);
    c=0;
    for (i=0; i<n; i++) {
        scanf("%d %d", &s, &e);
        rs[c].i=s; rs[c].k=1; c++;
        rs[c].i=e; rs[c].k=-1; c++;
    }
    r=1; for (i=1; i<=n; i++) { r*=k; r%=MOD; }
    sort(rs, rs+c, mycmp);
    bb=1;
    cc=0;
    for (i=0; i<c; i++) {
        j=rs[i].k; if (j<0) cc--; else {
            if (cc>=k) { bb=0; break; }
            bb*=(k-cc); bb%=MOD;
            cc++;
        }
    }
    r-=bb; if (r<0) r%=MOD;
    printf("%lld\n", r);
    return 0;
}
0