Submission #2211281
Source Code Expand
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible" ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
#define ALL(obj) (obj).begin(),(obj).end()
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
cin>>head;
CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
seco.resize(head);
VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
VECCIN(head);
VT2(move(tail)...);
}
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
seco[head]=IN();
VT3(head,move(tail)...);
}
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
#define str string
#define pb(a) push_back(a)
#define mp make_pair
class FordFulkerson{
public:
FordFulkerson(vector<M> ed,int n);
int Dfs(int v,int t,int f);
ll Solve(int s,int t);
int pnum;
vector<M> edges;
V flag;
};
FordFulkerson::FordFulkerson(vector<M> ed,int n){
pnum=n;
edges=ed;
}
int FordFulkerson::Dfs(int s,int t,int f){
if(s==t)return f;
flag[s]=true;
FOREACH(e,edges[s]){
if(!flag[e.first] && e.second>0){
int d = Dfs(e.first,t,min(f,e.second));
if(d>0){
e.second-=d;
edges[e.first][s]+=d;
return d;
}
}
}
return 0;
}
ll FordFulkerson::Solve(int s,int t){
ll ret=0;
while(1){
flag=V(pnum,0);
int f=Dfs(s,t,INF);
if(!f)return ret;
ret+=f;
}
}
int main(){
CIN(n,g,e);VC1(g,p);VC2(e,a,b);
vector<M> edges(n+1);//[i]:{(to,cost)}
REP(i,e){
edges[a[i]][b[i]]=1;
edges[b[i]][a[i]]=1;
}
REP(i,g)
edges[p[i]][n]=1;//マークしている人からsink(edges[n])に有向辺が生えてるとする
FordFulkerson calc(edges,n+1);
COUT(calc.Solve(0,n));
return 0;
}
Submission Info
Submission Time |
|
Task |
D - 浮気予防 |
User |
shibh308 |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
3912 Byte |
Status |
AC |
Exec Time |
15 ms |
Memory |
1664 KB |
Judge Result
Set Name |
part |
All |
Score / Max Score |
99 / 99 |
1 / 1 |
Status |
|
|
Set Name |
Test Cases |
part |
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 |
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 |
Case Name |
Status |
Exec Time |
Memory |
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 |
AC |
1 ms |
256 KB |
test_03_AB.txt |
AC |
1 ms |
256 KB |
test_04_AB.txt |
AC |
1 ms |
256 KB |
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 |
AC |
1 ms |
256 KB |
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 |
AC |
15 ms |
1664 KB |
test_27_A.txt |
AC |
12 ms |
1664 KB |
test_28_A.txt |
AC |
11 ms |
1664 KB |
test_29_A.txt |
AC |
9 ms |
1664 KB |
test_30_A.txt |
AC |
7 ms |
1664 KB |
test_31_A.txt |
AC |
11 ms |
1664 KB |
test_32_A.txt |
AC |
2 ms |
384 KB |
test_33_A.txt |
AC |
4 ms |
896 KB |
test_34_A.txt |
AC |
2 ms |
384 KB |
test_35_A.txt |
AC |
2 ms |
512 KB |
test_36_A.txt |
AC |
2 ms |
384 KB |
test_37_A.txt |
AC |
4 ms |
768 KB |
test_38_A.txt |
AC |
1 ms |
256 KB |
test_39_A.txt |
AC |
1 ms |
256 KB |
test_40_A.txt |
AC |
1 ms |
256 KB |
test_41_AB.txt |
AC |
1 ms |
256 KB |
test_42_A.txt |
AC |
4 ms |
896 KB |
test_43_A.txt |
AC |
1 ms |
256 KB |
test_44_A.txt |
AC |
2 ms |
512 KB |
test_45_A.txt |
AC |
1 ms |
256 KB |
test_46_A.txt |
AC |
1 ms |
256 KB |
test_47_AB.txt |
AC |
1 ms |
256 KB |
test_48_A.txt |
AC |
1 ms |
256 KB |
test_49_A.txt |
AC |
1 ms |
256 KB |
test_50_A.txt |
AC |
1 ms |
256 KB |
test_51_A.txt |
AC |
1 ms |
256 KB |