結果

問題 No.1745 Selfish Spies 2 (à la Princess' Perfectionism)
ユーザー cureskolcureskol
提出日時 2021-11-14 22:00:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 5,013 ms
コンパイル使用メモリ 265,568 KB
実行使用メモリ 46,304 KB
最終ジャッジ日時 2024-11-30 07:30:52
合計ジャッジ時間 10,576 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 56
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   27 |     auto [from,to,cap,flow]=edges[i];
      |          ^
main.cpp:34:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   34 |     auto [from,to,cap,flow]=edges[l+i];
      |          ^
main.cpp:39:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   39 |     auto [from,to,cap,flow]=edges[l+n+j];
      |          ^
main.cpp:45:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   45 |     auto [from,to,cap,flow]=edges[i];
      |          ^

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m,l;cin>>n>>m>>l;
  mf_graph<int> fl(n+m+2);
  int S=n+m,T=n+m+1;
  REP(_,l){
    int s,t;cin>>s>>t;s--;t--;
    fl.add_edge(s,n+t,1);
  }
  REP(i,n)fl.add_edge(S,i,1);
  REP(j,m)fl.add_edge(n+j,T,1);
  fl.flow(S,T);
  scc_graph g(n+m);
  auto edges=fl.edges();
  REP(i,l){
    auto [from,to,cap,flow]=edges[i];
    if(flow)g.add_edge(from,to);
    else g.add_edge(to,from);
  }
  auto A=g.scc();
  dsu uf(n+m),uf2(n+m+2);
  REP(i,n){
    auto [from,to,cap,flow]=edges[l+i];
    if(flow)uf2.merge(n+m,to);
    else uf2.merge(n+m+1,to);
  }
  REP(j,m){
    auto [from,to,cap,flow]=edges[l+n+j];
    if(flow)uf2.merge(n+m,from);
    else uf2.merge(n+m+1,from);
  }
  for(auto v:A)for(int p:v)uf.merge(v[0],p);
  REP(i,l){
    auto [from,to,cap,flow]=edges[i];
    if(flow||uf.same(from,to)||uf2.same(from,n+m)||uf2.same(to,n+m))cout<<"Yes\n";
    else cout<<"No\n";
  }
}
0