이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
const int N=1e5+5,M=15;
int T,k,sz[N][M],p[N][M];
vector<int> g[N];
void make_set(int v, int t) {
p[v][t]=v; sz[v][t]=1;
}
int find_set(int v, int t) {
if (p[v][t]==v) return v;
return p[v][t]=find_set(p[v][t],t);
}
void merge(int a, int b, int t) {
a=find_set(a,t); b=find_set(b,t);
if (a==b) return;
if (sz[a][t]<sz[b][t]) swap(a,b);
sz[a][t]+=sz[b][t]; p[b][t]=a;
}
void add_edges(int v, int t) {
for (auto u:g[v]) if (p[u][t]>=0) merge(u,v,t);
}
int solve(int n, int m, vector<int> F,vector<vector<int>> S) {
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) p[i][j]=-1;
g[i].clear();
}
for (int i=1; i<n; i++) {
g[i].pb(F[i]); g[F[i]].pb(i);
}
int ans=0;
for (int i=0; i<m; i++) make_set(0,i);
set<int> myset[m];
for (int i=n-2; i>=0; i--) {
bool check=1;
for (int j=0; j<m; j++) {
int x=S[j][i];
myset[j].insert(x);
make_set(x,j);
add_edges(x,j);
if (sz[find_set(x,j)][j]!=n-i) check=0;
}
if (n<=1000) {
for (int j=1; j<m; j++) {
if (myset[j]!=myset[j-1]) check=0;
}
}
if (check) ans++;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
september.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
# | 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... |