結果
| 問題 | No.1293 2種類の道路 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-11-30 05:56:52 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 542 bytes | 
| コンパイル時間 | 946 ms | 
| コンパイル使用メモリ | 97,148 KB | 
| 最終ジャッジ日時 | 2024-07-02 20:55:43 | 
| 合計ジャッジ時間 | 1,749 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:6:8: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
    6 |   ios::sync_with_stdio(false);
      |        ^~~~~~~~~~~~~~~
main.cpp:7:3: error: 'cin' was not declared in this scope
    7 |   cin.tie(0);
      |   ^~~
main.cpp:3:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    2 | #include<set>
  +++ |+#include <iostream>
    3 | using namespace std;
main.cpp:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<ans<<'\n';
      |   ^~~~
main.cpp:32:3: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
            
            ソースコード
#include<atcoder/all>
#include<set>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,d,w,u,v;
  cin>>n>>d>>w;
  atcoder::dsu uf1(n),uf2(n);
  while(d--){
    cin>>u>>v;
    uf1.merge(--u,--v);
  }
  while(w--){
    cin>>u>>v;
    uf2.merge(--u,--v);
  }
  auto G=uf1.groups();
  long ans=0,cnt;
  for(auto a:G){
    cnt=-1;
    set<int> S;
    for(auto v:a){
      if(!S.count(u=uf2.leader(v))){
        cnt+=uf2.size(u);
        S.insert(u);
      }
    }
    ans+=cnt*a.size();
  }
  cout<<ans<<'\n';
}
            
            
            
        