結果

問題 No.826 連絡網
ユーザー satou_a_mansatou_a_man
提出日時 2019-05-03 22:08:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 205,768 KB
実行使用メモリ 75,868 KB
最終ジャッジ日時 2023-08-30 06:09:51
合計ジャッジ時間 11,005 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

void merge(int a, int b, vector<set<int>>& uf) {
  if(a>b) {
    swap(a,b);
  }
  // a<=b
  for(auto& x : uf[a]) {
    uf[b].insert(x);
  }
  uf[a].clear();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,p;
  cin>>n>>p;
  vector<set<int>> uf(n+1);
  for(int x=1; x<=n; x++) uf[x].insert(x);
  for(int k=2; k<n; k++) {
    int s=k;
    while(s+k<=n) {
      merge(s,s+k,uf);
      s+=k;
    }
  }
  for(int x=1; x<=n; x++) {
    if(uf[x].find(p)!=uf[x].end()) {
      cout << uf[x].size() << endl;
    }
  }
  return 0;
}
0