이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define ff first
#define ss second
#define MP make_pair
const pii SP(int a, int b) { return MP(min(a, b), max(a, b)); }
template<typename T> void ono_min(T &MIN, T CMP) { if(MIN > CMP) MIN = CMP; }
const int mxn = 1e6 + 10;
vector<int> adj[mxn];
int n, m, TIME, col[mxn];
int vis[mxn], low[mxn];
stack<int> st;
bool in[mxn];
void dfs(int u) {
vis[u] = low[u] = TIME++;
st.push(u);
in[u] = 1;
for(int v : adj[u]) {
if(!vis[v]) {
dfs(v);
ono_min(low[u], low[v]);
} else if(in[v]) {
ono_min(low[u], low[v]);
}
}
if(low[u] == vis[u]) {
while(st.top() != u) {
col[st.top()] = u;
in[st.top()] = 0;
st.pop();
}
st.pop();
in[u] = 0;
}
}
int solve(int N, int M, vector<int> F, vector<vector<int>> S) {
set<pii> edges;
for(int i = 1; i < N; i++)
if(F[i] != 0)
edges.insert(MP(i, F[i]));
for(const auto &v : S)
for(int i = 0; i < v.size() - 1; i++)
edges.insert(MP(v[i], v[i + 1]));
for(pii p : edges) {
int u = p.ff;
int v = p.ss;
adj[u].push_back(v);
}
// for(int i = 0; i < N; i++) {
// cout << i << ": ";
// for(int j : adj[i])
// cout << j << ' ';
// cout << endl;
// }
for(int i = 0; i < N; i++)
col[i] = i;
for(int i = 0; i < N; i++)
if(vis[i] == 0)
dfs(i);
int cnt = 0;
for(int i = 1; i < N; i++)
if(col[i] == i)
cnt++;
return cnt;
}
컴파일 시 표준 에러 (stderr) 메시지
september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i = 0; i < v.size() - 1; i++)
| ~~^~~~~~~~~~~~~~
# | 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... |