제출 #1359532

#제출 시각아이디문제언어결과실행 시간메모리
1359532Mamikonm19월 (APIO24_september)C++20
0 / 100
1 ms344 KiB
#include "september.h"
#include <iostream>
#include <vector>
#include <cmath>
#include<map>
#include <algorithm>
#include <iomanip>
#include <string>
#include<stack>
#include <set>
#include <queue>
#include <chrono>
#include<array>
#include<bitset>
#include<unordered_map>
#include<random>
#include<cassert>
#include<cstring>
using namespace std;
using ll = long long;
using db = double;
const float pi = 3.14159265359;
#define V vector
#define VI V<int>
#define P pair<int,int>
#define rep(i, a, b, step) for (int i = int(a); i <= int(b); i += step)
#define repl(i,a,b,step) for (int i = int(a); i >= int(b); i -= step)
#define prime(n) [](int x) { for (int i = 2; i *1ll* i <= x; ++i) if (x % i == 0) return false; return x > 1; }(n)
#define printall(container, ch) for (const auto& elem : container) { std::cout << elem << ch; } std::cout << std::endl;
#define sn << '\n'
#define ed << endl
#define sz size()
#define print cout <<
#define debug(x) cerr<< #x << " = " << x sn;
#define mpII map<int,int>   
#define mine min_element    
#define maxe max_element    
#define all(v) begin(v), end(v)
#define txt freopen("snakes.in", "r", stdin); freopen("snakes.out", "w", stdout)    
#define MEX(a) [](VI a){set<int>elem;for(auto&i:a)elem.insert(i);int ret=0;while(elem.count(ret))ret++;return ret;}(a)
#define pb push_back    
#define pq priority_queue
#define rev reverse
#define nuyn(a) a.erase(unique(all(a)), end(a))
#define nx next_permutation         
#define pk pop_back()
#define START print "Start" sn
#define END print "End" sn
#define ff first
#define ss second       
#define ts to_string 
#define ub upper_bound       
#define mk make_pair 
#define lb lower_bound               
#define testcase int t;cin>>t;while(t--)solution();
int solve(int n, int m, std::vector<int> f, std::vector<std::vector<int>> s) {
	VI dp(n), cnt(n), deg(n), d(n), ind(n);
	int cntok, mxr, mnl, u;
	rep(i, 1, n - 1, 1)deg[f[i]]++;
	rep(i, 0, n - 2, 1)ind[s[0][i]] = i;
	rep(i, 0, n - 2, 1) {
		cntok = 0; 
		mxr = -1;
		mnl = n;
		rep(j, 0, n - 1, 1)cnt[j] = 0, d[j] = deg[j];
		rep(j, i, n - 2, 1) {
			for (u = s[0][j]; u;) {
				if (d[u])break;
				mxr = max(mxr, ind[u]);
				mnl = min(mnl, ind[u]);
				if (!--d[f[u]])u = f[u];
				else break;
			}
			rep(k, 0, m - 1, 1)cntok += (++cnt[s[k][j]] == m);
			if (cntok == j - i + 1 and mxr <= j and mnl >= i)dp[j + 1] = max(dp[j + 1], dp[i] + 1);
		}
	}
	return dp[n - 1];
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…