結果
問題 | No.1502 Many Simple Additions |
ユーザー | auaua |
提出日時 | 2021-05-07 22:55:39 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,381 bytes |
コンパイル時間 | 1,688 ms |
コンパイル使用メモリ | 177,472 KB |
実行使用メモリ | 13,512 KB |
最終ジャッジ日時 | 2023-10-13 14:14:17 |
合計ジャッジ時間 | 5,247 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,352 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,352 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,352 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
4,348 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
4,348 KB |
testcase_13 | AC | 1 ms
4,348 KB |
testcase_14 | AC | 2 ms
4,348 KB |
testcase_15 | AC | 1 ms
4,356 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 2 ms
4,348 KB |
testcase_27 | AC | 113 ms
12,492 KB |
testcase_28 | AC | 112 ms
12,280 KB |
testcase_29 | AC | 8 ms
7,984 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 85 ms
6,716 KB |
testcase_37 | WA | - |
testcase_38 | AC | 99 ms
8,832 KB |
testcase_39 | AC | 62 ms
6,320 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 135 ms
11,844 KB |
testcase_43 | AC | 1 ms
4,348 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vector<ll> > #define fi first #define se second #define double long double typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; //typedef long double ld; typedef complex<double> Complex; const ll INF=1e9+7; const ll MOD=INF; const ll inf=INF*INF; const ll mod=MOD; const ll MAX=100010; signed main(){ ll n,m,k;cin>>n>>m>>k; vector<vector<pll> >G(n); rep(i,m){ ll x,y,z; cin>>x>>y>>z; x--;y--; G[x].pb(mp(y,z)); G[y].pb(mp(x,z)); } ll ans=1; { queue<ll>q; vector<ll>mi(n,1),ma(n,k); vector<ll>used(n); rep(i,n){ if(used[i])continue; q.push(i); used[i]=1; ll res=k; while(!q.empty()){ ll v=q.front(); q.pop(); res=min(res,ma[v]-mi[v]+1); for(auto e:G[v]){ if(!used[e.fi]){ q.push(e.fi); used[e.fi]=1; } mi[e.fi]=max(mi[e.fi],e.se-ma[v]); ma[e.fi]=min(ma[e.fi],e.se-mi[v]); mi[e.fi]=min(mi[e.fi],k); ma[e.fi]=max(ma[e.fi],1LL); } } res=max(res,0LL); ans=ans*res%mod; } } ll ans2=1; k=k-1; { queue<ll>q; vector<ll>mi(n,1),ma(n,k); vector<ll>used(n); ll ans=1; rep(i,n){ if(used[i])continue; q.push(i); used[i]=1; ll res=k; while(!q.empty()){ ll v=q.front(); q.pop(); res=min(res,ma[v]-mi[v]+1); for(auto e:G[v]){ if(!used[e.fi]){ q.push(e.fi); used[e.fi]=1; } mi[e.fi]=max(mi[e.fi],e.se-ma[v]); ma[e.fi]=min(ma[e.fi],e.se-mi[v]); mi[e.fi]=min(mi[e.fi],k); ma[e.fi]=max(ma[e.fi],1LL); } } res=max(res,0LL); ans=ans*res%mod; } ans2=ans; } ll an=(ans-ans2+mod)%mod; cout<<an<<endl; }