# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085360 | IUA_Hasin | 9월 (APIO24_september) | C++17 | 371 ms | 39232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
ll deg[N], vis[N];
for(int i=0; i<N; i++){
deg[i] = 0;
vis[i] = 0;
}
for(int i=1; i<F.size(); i++){
ll a = F[i];
deg[i]++;
deg[a]++;
}
if(M==0){
ll ans = 0;
set<ll> s;
for(int i=0; i<S.size(); i++){
for(int j=0; j<S[i].size(); j++){
ll a = S[i][j];
ll parnt = F[a];
deg[a]--;
deg[parnt]--;
//cout << deg[a] << " " << deg[parnt] << endl;
auto it = s.find(parnt);
if(deg[a]!=0){
s.insert(a);
}
if(it!=s.end()){
if(deg[parnt]==0){
s.erase(it);
}
}
if(s.size()==0){
ans++;
}
for(auto u : s){
cout << u << " ";
}
//cout << i << " " << 59;
cout<<endl;
}
}
return ans;
} else {
set<ll> world;
set<ll> s[M];
set<ll> check;
ll ans = 0;
for(int i=0; i<S[0].size(); i++){
for(int j=0; j<M; j++){
ll a = S[j][i];
ll parnt = F[a];
world.insert(a);
s[j].insert(a);
if(vis[a]==0){
deg[a]--;
deg[parnt]--;
auto it = check.find(parnt);
if(deg[a]!=0){
check.insert(a);
}
if(it!=check.end()){
if(deg[parnt]==0){
check.erase(it);
}
}
vis[a] = 1;
}
// for(auto u : check){
// cout << u << " ";
// }
// cout<<endl;
}
ll status = 1;
ll siz = world.size();
for(int j=0; j<M; j++){
ll a = s[j].size();
if(a!=siz){
status = -1;
break;
}
}
if(status==1 && check.size()==0){
ans++;
}
// cout<<endl;
// for(auto u : check){
// cout << u << " ";
// }
// cout<<endl;
}
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |