結果
| 問題 |
No.3103 Butterfly Effect
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-11 22:09:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,764 bytes |
| コンパイル時間 | 1,677 ms |
| コンパイル使用メモリ | 166,868 KB |
| 実行使用メモリ | 129,468 KB |
| 最終ジャッジ日時 | 2025-04-11 22:10:26 |
| 合計ジャッジ時間 | 24,766 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 36 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘void dfs(long long int)’:
main.cpp:31:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
31 | auto [t,y]=(*it);g[x].erase(it);
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*1LL*u)%p;} else {int u=po(a,b-1);return (a*1LL*u)%p;}}
int inv(int x) {return po(x,p-2);}
mt19937 rnd;
#define app push_back
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0)
#else
#define debug(...)
#define debugv(v)
#endif
#define lob(a,x) lower_bound(all(a),x)
#define upb(a,x) upper_bound(all(a),x)
const int inf=1e18;
const int maxn=1e6+5;
int mom[maxn];
set<pair<int,int> > g[maxn];
int ans=1;
void dfs(int x)
{
if(g[x].empty()) return;
while(!g[x].empty())
{
set<pair<int,int> >::iterator it=(--g[x].end());
auto [t,y]=(*it);g[x].erase(it);
if(t<mom[x]) {break;}
if(mom[y]>t)
{
if(mom[y]==inf) {++ans;}
mom[y]=t;dfs(y);
}
else
{
}
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mom[0]=0;fill(mom+1,mom+maxn,inf);
int n,q;cin>>n>>q;
while(q--)
{
int t,x,y;cin>>t>>x>>y;--x;--y;
g[x].insert({t,y});g[y].insert({t,x});
if(mom[x]<t && mom[y]>t)
{
if(mom[y]==inf) {++ans;}
mom[y]=t;
dfs(y);
}
if(mom[x]>t && mom[y]<t)
{
if(mom[x]==inf) {++ans;}
mom[x]=t;
dfs(x);
}
cout<<ans<<'\n';
}
return 0;
}