제출 #1009328

#제출 시각아이디문제언어결과실행 시간메모리
1009328Cookie9월 (APIO24_september)C++17
100 / 100
100 ms17900 KiB
#include<bits/stdc++.h> #include<fstream> //#pragma GCC optimize("O3") //#pragma GCC target("avx2") using namespace std; #define sz(a) (int)a.size() #define ALL(v) v.begin(), v.end() #define ALLR(v) v.rbegin(), v.rend() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> #define mpp make_pair const ld PI = 3.14159265359, prec = 1e-9;; //using u128 = __uint128_t; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; const ll mod = 1e9 + 7, pr = 31; const int mxn = 2e5 + 5, mxd = 250 * 250, sq = 100, mxv = 5e4 + 1, mxq = 2e6 + 5, T = 1000; //const int base = (1 <<18); const ll inf = 2e9 + 5, neg = -69420, inf2 = 1e14; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); #include <vector> #include <cassert> #include <cstdio> //#include "september.h" #include <vector> int n, m; bool vis[mxn + 1]; vt<int>adj[mxn + 1]; int cnt = 0; void dfs(int s){ cnt += m; vis[s] = 1; for(auto i: adj[s]){ if(!vis[i]){ dfs(i); } } } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { n = N; m = M; cnt = 0; for(int i = 0; i < N; i++){ adj[i].clear(); vis[i] = 0; } for(int i = 1; i < N; i++){ adj[F[i]].pb(i); } int ans = 0; for(int i = 0; i < N - 1; i++){ for(int j = 0; j < M; j++){ if(!vis[S[j][i]])dfs(S[j][i]); } cnt -= M; if(cnt == 0)ans++; } return(ans); } /* #include <vector> void taskcase() { int N, M; assert(2 == scanf("%d%d", &N, &M)); std::vector<int> F(N); F[0] = -1; for (int i = 1; i < N; ++i) assert(1 == scanf("%d", &F[i])); std::vector<std::vector<int>> S(M, std::vector<int>(N - 1)); for (int i = 0; i < M; ++i) for (int j = 0; j < N - 1; ++j) assert(1 == scanf("%d", &S[i][j])); printf("%d\n", solve(N, M, F, S)); } int main() { int T; assert(1 == scanf("%d", &T)); while(T--) taskcase(); return 0; } */
#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...