이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
bool is_equal[N], check[N], ss[N], vis[N];
int par[N], cnt[N];
int a[5][N], n, m;
vector<int> g[N];
int solve(int N_, int M, vector<int> F, vector<vector<int>> S) {
n=N_, m=M;
for (int i=0; i<m; ++i) for (int j=1; j<n; ++j) a[i][j]=S[i][j-1]+1;
for (int i=1; i<=n; ++i) par[i]=F[i-1]+1, g[par[i]].push_back(i);
int sum=0;
for (int i=1; i<n; ++i){
int u=a[0][i];
if (vis[par[u]]) --sum, ss[u]=0;
for (int v:g[u]){
if (!vis[v]) ss[v]=1, ++sum;
}
vis[u]=1;
check[i]=!sum;
is_equal[i]=1;
}
for (int j=1; j<m; ++j){
sum=0;
for (int i=1; i<n; ++i){
if (a[0][i]!=a[j][i]){
sum-=!!cnt[a[0][i]];
sum-=!!cnt[a[j][i]];
++cnt[a[0][i]]; --cnt[a[j][i]];
sum+=!!cnt[a[0][i]];
sum+=!!cnt[a[j][i]];
}
is_equal[i]&=!sum;
}
}
int ans=0;
for (int i=1; i<n; ++i) ans+=check[i] && is_equal[i];
return ans;
}
# | 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... |