제출 #1000738

#제출 시각아이디문제언어결과실행 시간메모리
1000738Boycl079월 (APIO24_september)C++17
59 / 100
121 ms16680 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 1; (i) <= (n); ++i) #define forn(i, l, r) for(int i = (l); i <= (r); ++i) #define ford(i, r, l) for(int i = (r); i >= (l); --i) #define FOR(i, n) for(int i = 0; i < (n); ++i) #define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i) #define fi first #define se second #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define endl "\n" #define task "note" #define sz(a) int(a.size()) #define C(x, y) make_pair(x, y) #define all(a) (a).begin(), (a).end() #define bit(i, mask) (mask >> i & 1) template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } inline int readInt() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();int n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;} inline ll readLong() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();ll n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;} inline string readString() {char c;while(c=getchar(),c==' '||c=='\n'||c=='\t');string s({c});while(c=getchar(),c!=EOF&&c!=' '&&c!='\n'&&c!='\t')s+=c;return s;} const int MaxN = 1e5 + 3; const int MaxM = 6; vector<int> g[MaxN]; struct volunteers { int num_cc; int del[MaxN]; int n; void init(int N) { n = N; num_cc = 1; FOR(i, N) del[i] = 0; } bool check() {return num_cc == 1;} void add(int x) { del[x] = 1; --num_cc; for(int v : g[x]) num_cc += !del[v]; } } f[MaxM]; bool check(int M) { FOR(i, M) if(!f[i].check()) return 0; return 1; } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { FOR(i, N) g[i].clear(); rep(i, N - 1) g[F[i]].pb(i), g[i].pb(F[i]); FOR(i, M) f[i].init(N); int res = 0; FOR(i, N - 1) { FOR(j, M) f[j].add(S[j][i]); if(check(M)) ++res; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...