AtCoder Beginner Contest 010

Submission #1679283

Source codeソースコード

#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define yo 100001
//------------------変数-----------------------//
//-------------------関数----------------------//
struct Fordfulkerson{

 struct edge{
   ll to,cap,rev;
   edge(){}
   edge(ll to,ll cap,ll rev):to(to),cap(cap),rev(rev){}
 };

 vector<vector<edge> > G;
 vector<ll> used;

 Fordfulkerson(){}
 Fordfulkerson(ll V){init(V);}

 void init(ll V){
   for(int i=0;i<(ll)G.size();i++) G[i].clear();
   G.clear();
   used.clear();
   G.resize(V);
   used.resize(V);
 }

 void add_edge(ll from,ll to,ll cap){
   G[from].push_back(edge(to,cap,G[to].size()));
   // undirected
   //G[to].push_back(edge(from,cap,G[from].size()-1));
   // directed
   G[to].push_back(edge(from,0,G[from].size()-1));
 }

 ll dfs(ll v,ll t,ll f){
   if(v==t) return f;
   used[v]=true;
   for(ll i=0;i<(int)G[v].size();i++){
     edge &e = G[v][i];
     if(!used[e.to] && e.cap > 0 ){
 ll d=dfs(e.to,t,min(f,e.cap));
 if(d>0){
   e.cap-=d;
   G[e.to][e.rev].cap+=d;
   return d;
 }
     }
   }
   return 0;
 }

 ll max_flow(ll s,ll t){
   ll flow=0;
   for(;;){
     fill(used.begin(),used.end(),0);
     ll f=dfs(s,t,INF);
     if(f==0) return flow;
     flow+=f;
   }
 }
};
int main(){
  ll n,g,e;
  cin>>n>>g>>e;
  Fordfulkerson ford(n+1);
  ll p[114];
  REP(i,g){
    cin>>p[i];
    ford.add_edge(p[i],n,1);
  }
  REP(i,e){
    ll a,b;cin>>a>>b;
    ford.add_edge(a,b,1);
  }
  cout<<ford.max_flow(0,n)<<endl;
	return 0;
}

Submission

Task問題 D - 浮気予防
User nameユーザ名 keidaroo
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 2247 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
part 0 / 99 test_01_AB.txt,test_02_AB.txt,test_03_AB.txt,test_04_AB.txt,test_05_AB.txt,test_06_AB.txt,test_07_AB.txt,test_08_AB.txt,test_09_AB.txt,test_10_AB.txt,test_11_AB.txt,test_12_AB.txt,test_13_AB.txt,test_14_AB.txt,test_15_AB.txt,test_16_AB.txt,test_17_AB.txt,test_18_AB.txt,test_19_AB.txt,test_20_AB.txt,test_21_AB.txt,test_22_AB.txt,test_23_AB.txt,test_24_AB.txt,test_25_AB.txt,test_41_AB.txt,test_47_AB.txt
All 0 / 1 sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,sample_05.txt,sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,sample_05.txt,test_01_AB.txt,test_02_AB.txt,test_03_AB.txt,test_04_AB.txt,test_05_AB.txt,test_06_AB.txt,test_07_AB.txt,test_08_AB.txt,test_09_AB.txt,test_10_AB.txt,test_11_AB.txt,test_12_AB.txt,test_13_AB.txt,test_14_AB.txt,test_15_AB.txt,test_16_AB.txt,test_17_AB.txt,test_18_AB.txt,test_19_AB.txt,test_20_AB.txt,test_21_AB.txt,test_22_AB.txt,test_23_AB.txt,test_24_AB.txt,test_25_AB.txt,test_26_A.txt,test_27_A.txt,test_28_A.txt,test_29_A.txt,test_30_A.txt,test_31_A.txt,test_32_A.txt,test_33_A.txt,test_34_A.txt,test_35_A.txt,test_36_A.txt,test_37_A.txt,test_38_A.txt,test_39_A.txt,test_40_A.txt,test_41_AB.txt,test_42_A.txt,test_43_A.txt,test_44_A.txt,test_45_A.txt,test_46_A.txt,test_47_AB.txt,test_48_A.txt,test_49_A.txt,test_50_A.txt,test_51_A.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
sample_05.txt AC 1 ms 256 KB
test_01_AB.txt AC 1 ms 256 KB
test_02_AB.txt WA
test_03_AB.txt WA
test_04_AB.txt WA
test_05_AB.txt AC 1 ms 256 KB
test_06_AB.txt AC 1 ms 256 KB
test_07_AB.txt AC 1 ms 256 KB
test_08_AB.txt AC 1 ms 256 KB
test_09_AB.txt AC 1 ms 256 KB
test_10_AB.txt AC 1 ms 256 KB
test_11_AB.txt WA
test_12_AB.txt AC 1 ms 256 KB
test_13_AB.txt AC 1 ms 256 KB
test_14_AB.txt AC 1 ms 256 KB
test_15_AB.txt AC 1 ms 256 KB
test_16_AB.txt AC 1 ms 256 KB
test_17_AB.txt AC 1 ms 256 KB
test_18_AB.txt AC 1 ms 256 KB
test_19_AB.txt AC 1 ms 256 KB
test_20_AB.txt AC 1 ms 256 KB
test_21_AB.txt AC 1 ms 256 KB
test_22_AB.txt AC 1 ms 256 KB
test_23_AB.txt AC 1 ms 256 KB
test_24_AB.txt AC 1 ms 256 KB
test_25_AB.txt AC 1 ms 256 KB
test_26_A.txt WA
test_27_A.txt WA
test_28_A.txt AC 3 ms 640 KB
test_29_A.txt AC 3 ms 640 KB
test_30_A.txt AC 3 ms 640 KB
test_31_A.txt WA
test_32_A.txt WA
test_33_A.txt AC 2 ms 384 KB
test_34_A.txt AC 1 ms 256 KB
test_35_A.txt WA
test_36_A.txt WA
test_37_A.txt WA
test_38_A.txt WA
test_39_A.txt WA
test_40_A.txt AC 1 ms 256 KB
test_41_AB.txt AC 1 ms 256 KB
test_42_A.txt AC 2 ms 384 KB
test_43_A.txt AC 1 ms 256 KB
test_44_A.txt WA
test_45_A.txt WA
test_46_A.txt WA
test_47_AB.txt WA
test_48_A.txt AC 1 ms 256 KB
test_49_A.txt WA
test_50_A.txt WA
test_51_A.txt AC 1 ms 256 KB