結果

問題 No.2197 Same Dish
ユーザー lddlinanlddlinan
提出日時 2023-03-14 15:38:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 3,110 ms
コンパイル使用メモリ 87,752 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 11:45:04
合計ジャッジ時間 4,773 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 32 ms
4,348 KB
testcase_22 AC 36 ms
4,348 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 s, e; } RNode;
RNode rs[100004];
bool mycmp(const RNode& a, const RNode& b) { return a.s<b.s; }
int sx[100004];
#define MOD 998244353
int main() {
    int n, i, k, ck, s, e, j, nj, d, cc;
    LL b, r, bb, v, t;
    scanf("%d %d", &n, &k);
    for (i=0; i<n; i++) scanf("%d %d", &rs[i].s, &rs[i].e);
    r=1; for (i=1; i<=n; i++) { r*=k; r%=MOD; }
    sort(rs, rs+n, mycmp);
    bb=1;
    for (i=n-1; i>=0; i--) {
        s=rs[i].s; e=rs[i].e-1;
        j=i; d=n-i; while(d) {
            while(1) {
                nj=j+d; if (nj>=n) break;
                if (rs[nj].s>e) break;
                j=nj;
            }
            d>>=1;
        }
        cc=j-i;
        if (cc>=k) { bb=0; break; }
        bb*=(k-cc); bb%=MOD;
    }
    r-=bb; if (r<0) r%=MOD;
    printf("%lld\n", r);
    return 0;
}
0