結果
| 問題 | No.826 連絡網 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-24 13:32:42 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 27 ms / 2,000 ms |
| + 788µs | |
| コード長 | 2,029 bytes |
| 記録 | |
| コンパイル時間 | 2,504 ms |
| コンパイル使用メモリ | 337,892 KB |
| 実行使用メモリ | 9,856 KB |
| 最終ジャッジ日時 | 2026-10-24 13:32:48 |
| 合計ジャッジ時間 | 5,277 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 33 |
ソースコード
/*
#include<kyopro/master>
void self::main(){
LL(N,X);
DsuPlain uf(N+1);
fo(i,2,N+1){
fo(j,i*2,N+1,i){
uf.merge(i,j);
}
}
pp(uf.size(X));
}
*/
#include<bits/stdc++.h>
using namespace std;
namespace self{void main();void sub();template<ostream&o>void pp(const auto&...a);void epp(const auto&...a);}
int main(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);self::main();}
#define RD(T,...) T __VA_ARGS__;lin(__VA_ARGS__)
#define LL(...) RD(ll,__VA_ARGS__)
#define fo(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(0,__VA_ARGS__);i<i##stop;i+=i##step)
namespace self{
using ll=long long;
template<class T>constexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};}
void lin(auto&...a){(cin>>...>>a);}
template<class...A>using pack_back_t=tuple_element_t<sizeof...(A)-1,tuple<A...>>;
}
namespace self{
template<class V>struct vec;
template<int D,class T>struct hvec_helper{using type=vec<typename hvec_helper<D-1,T>::type>;};
template<class T>struct hvec_helper<0,T>{using type=T;};
template<int D,class T>using hvec=hvec_helper<D,T>::type;
template<class V>struct vec:vector<V>{
using vector<V>::vector;
};
template<class...A>requires(sizeof...(A)>=2)vec(const A&...a)->vec<hvec<sizeof...(A)-2,pack_back_t<A...>>>;
}
namespace self{
class DsuPlain{
public:
ll n_;
vec<int>par_or_size_;
DsuPlain(ll n):n_(n),par_or_size_(n,-1){}
auto merge(ll a,ll b){
ll x=leader(a),y=leader(b);
if(x==y)return x;
if(-par_or_size_[x]<-par_or_size_[y])swap(x,y),swap(a,b);
par_or_size_[x]+=par_or_size_[y];
par_or_size_[y]=x;
return x;
}
ll leader(ll a){
if(par_or_size_[a]<0)return a;
return par_or_size_[a]=leader(par_or_size_[a]);
}
ll size(ll a){return-par_or_size_[leader(a)];}
};
}
template<ostream&o=cout>void self::pp(const auto&...a){const char*c="";((o<<c<<a,c=" "),...);o<<'\n';}
void self::main(){
LL(N,X);
DsuPlain uf(N+1);
fo(i,2,N+1){
fo(j,i*2,N+1,i){
uf.merge(i,j);
}
}
pp(uf.size(X));
}