Submission #341168

#TimeUsernameProblemLanguageResultExecution timeMemory
341168amunduzbaevMarriage questions (IZhO14_marriage)C++14
36 / 100
1599 ms5828 KiB
/** made by amunduzbaev **/ #include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(),x.rend() #define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define vll vector<ll> #define vii vector<int> #define vpii vector<pii> #define vpll vector<pll> #define cnt(a)__builtin_popcount(a) template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;} template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;} const int N = 5000; const int mod = 1e9+7; const ll inf = 1e18; const ld Pi = acos(-1); ll a[N], s, n, m, k, ans; vector<vii> edges(N); bool find(int u, int l, int r, vii used){ if(u == m) return 1; bool ok = 0; for(auto x : edges[u]){ if(used[x] || x < l || x > r) continue; used[x] = 1; ok |= find(u+1, l, r, used); used[x] = 0; }return ok; } void solve(){ cin>>n>>m>>k; for(int i=0;i<k;i++){ int a, b; cin>>a>>b; edges[--b].pb(--a); // edges[a].pb(b); } for(int i=0;i<n;i++){ for(int j=i;j<n;j++){ vii tmp(n, 0); ans += find(0, i, j, tmp); //cout<<i<<" "<<j<<" "<<ans<<endl; } }cout<<ans<<endl; return; } int main(){ fastios int t = 0; if(!t) solve(); else { cin>>t; while (t--) solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...