結果

問題 No.2588 Increasing Record
ユーザー lgswdnlgswdn
提出日時 2024-01-16 15:26:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,020 bytes
コンパイル時間 3,274 ms
コンパイル使用メモリ 209,980 KB
実行使用メモリ 813,924 KB
最終ジャッジ日時 2024-01-16 15:26:12
合計ジャッジ時間 7,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,660 KB
testcase_01 AC 6 ms
18,660 KB
testcase_02 AC 7 ms
18,664 KB
testcase_03 AC 7 ms
18,660 KB
testcase_04 AC 6 ms
18,660 KB
testcase_05 AC 6 ms
18,660 KB
testcase_06 AC 6 ms
18,660 KB
testcase_07 AC 6 ms
18,660 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 28 ms
22,664 KB
testcase_13 AC 28 ms
22,700 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//vanitas vanitatum et omnia vanitas
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=2e5+5,mod=998244353;
int n,f[N],id[N],m,s[N],t[N],sz[N];
vi e[N],g[N];

void merge(int u,int v) {
  if(sz[u]<sz[v]) swap(u,v);
  for(int x:g[v]) t[x]+=s[v]-s[u];
  for(int x:g[v]) id[x]=u;
  g[u].insert(g[u].end(),g[v].begin(),g[v].end());
}

signed main() {
  n=read(), m=read();
  rep(i,1,m) {
    int u=read(), v=read();
    if(u>v) swap(u,v);
    e[v].eb(u);
  }
  rep(i,1,n) id[i]=i, sz[i]=1, g[i].eb(i);
  rep(i,1,n) sort(e[i].begin(),e[i].end());
  rep(i,1,n) {
    f[i]=1;
    for(int j:e[i]) if(id[i]!=id[j]) {
      f[i]=(f[i]+s[id[j]]+t[j])%mod;
      merge(id[i],id[j]);
    }
    s[id[i]]=(s[id[i]]+f[i])%mod;
  }
  int ans=0;
  rep(i,1,n) ans=(ans+f[i])%mod;
  printf("%lld\n",ans);
  return 0;
}
0