結果

問題 No.2210 equence Squence Seuence
ユーザー maksimmaksim
提出日時 2023-02-10 22:14:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 172,016 KB
実行使用メモリ 9,436 KB
最終ジャッジ日時 2023-09-21 23:29:33
合計ジャッジ時間 8,478 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,044 KB
testcase_01 AC 4 ms
4,932 KB
testcase_02 AC 3 ms
4,920 KB
testcase_03 AC 91 ms
5,612 KB
testcase_04 WA -
testcase_05 AC 173 ms
6,408 KB
testcase_06 AC 145 ms
6,148 KB
testcase_07 AC 430 ms
8,320 KB
testcase_08 AC 4 ms
5,256 KB
testcase_09 AC 3 ms
4,984 KB
testcase_10 AC 4 ms
4,984 KB
testcase_11 WA -
testcase_12 AC 3 ms
5,044 KB
testcase_13 AC 526 ms
9,436 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 527 ms
9,312 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 4 ms
4,984 KB
testcase_20 AC 4 ms
4,920 KB
testcase_21 AC 4 ms
4,932 KB
testcase_22 WA -
testcase_23 AC 308 ms
8,248 KB
testcase_24 AC 220 ms
7,528 KB
testcase_25 AC 263 ms
7,988 KB
testcase_26 AC 374 ms
9,216 KB
testcase_27 AC 84 ms
6,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int32_t main()’ 内:
main.cpp:49:45: 警告: iteration 200003 invokes undefined behavior [-Waggressive-loop-optimizations]
   49 |     po[0]=1;for(int i=1;i<maxn;++i) {po[i+1]=(po[i]*base)%p;}
      |                                      ~~~~~~~^~~~~~~~~~~~~~~
main.cpp:49:26: 備考: within this loop
   49 |     po[0]=1;for(int i=1;i<maxn;++i) {po[i+1]=(po[i]*base)%p;}
      |                         ~^~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
const int base=363621;
const int maxn=2e5+5;
int po[maxn];
int ha[maxn];vector<int> a;
int get(int i,int j)
{
    return ((ha[j]-po[j-i]*ha[i])%p+p)%p;
}
bool cmp1(int i,int j)
{
    if(get(i,j)==get(i+1,j+1))
    {
        return true;
    }
    int low=i;int up=j;
    while(up-low>1)
    {
        int mid=(low+up)/2;
        if(get(i,mid)==get(i+1,mid+1)) low=mid;
        else up=mid;
    }
    return a[low]>a[low+1];
}
bool cmp(int i,int j)
{
    if(i==j) return false;
    if(i>j) return !cmp1(j,i);
    if(get(i,j)==get(i+1,j+1))
    {
        return false;
    }
    int low=i;int up=j;
    while(up-low>1)
    {
        int mid=(low+up)/2;
        if(get(i,mid)==get(i+1,mid+1)) low=mid;
        else up=mid;
    }
    return a[low]>a[low+1];
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    po[0]=1;for(int i=1;i<maxn;++i) {po[i+1]=(po[i]*base)%p;}
    int n,k;cin>>n>>k;a.resize(n);
    for(int i=0;i<n;++i) {cin>>a[i];ha[i+1]=(ha[i]*base+a[i])%p;}
    vector<int> v(n);iota(v.begin(),v.end(),0);
    sort(v.begin(),v.end(),cmp);
    a.erase(a.begin()+v[k-1]);
    for(int x:a) cout<<x<<' ';
    return 0;
}
0