이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn=2010;
#define MP make_pair
int n,m,p[maxn],r[maxn];
vector<pair<int,int> > g[maxn];
vector<pair<int,int> > rem[maxn];
int hd,tl,q[maxn];
bool vis_id[maxn],vis_col[maxn];
void insert_id(int x) {
if (vis_id[x]) return;
vis_id[x]=1;
if (!vis_col[r[x]]) {
for (pair<int,int> A : rem[r[x]]) {
insert_id(A.first);
}
}
q[++tl]=x;
vis_col[r[x]]=1;
}
vector<int> find_reachable(vector<int> R,vector<int> U,vector<int> V, vector<int> C) {
n=(int)R.size();
for (int i=0;i<n;i++) r[i+1]=R[i]+1;
m=(int)U.size(); int x,y,z;
for (int i=0;i<m;i++) {
x=U[i]+1,y=V[i]+1,z=C[i]+1;
g[x].push_back(MP(y,z)),g[y].push_back(MP(x,z));
}
int mn=n+1; vector<int> ans(n,0);
for (int s=1;s<=n;s++) {
memset(vis_id,0,sizeof(vis_id));
memset(vis_col,0,sizeof(vis_col));
for (int j=1;j<=n;j++) rem[j].clear();
hd=1,tl=0;
insert_id(s);
while (hd<=tl) {
int x=q[hd]; hd++;
for (pair<int,int> A : g[x]) {
int y=A.first; if (vis_id[y]) continue;
if (vis_col[A.second]) insert_id(y);
else rem[A.second].push_back(A);
}
}
p[s]=tl; mn=min(mn,tl);
}
for (int i=1;i<=n;i++) if (p[i]==mn) ans[i-1]=1; return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:46:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
46 | for (int i=1;i<=n;i++) if (p[i]==mn) ans[i-1]=1; return ans;
| ^~~
keys.cpp:46:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
46 | for (int i=1;i<=n;i++) if (p[i]==mn) ans[i-1]=1; 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... |