Submission #998591

#TimeUsernameProblemLanguageResultExecution timeMemory
998591dubabubaSeptember (APIO24_september)C++17
0 / 100
4 ms28252 KiB
#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; }

Compilation message (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...