Submission #332392

#TimeUsernameProblemLanguageResultExecution timeMemory
332392nicholaskSplit the Attractions (IOI19_split)C++14
0 / 100
7 ms7532 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; struct node{ vector <int> in,out; }g[100001]; bool visited[100001]; stack <int> st; vector <int> scc[100001]; int upto; void dfs1(int n){ visited[n]=1; for (auto&i:g[n].out){ if (!visited[i]) dfs1(i); } st.push(n); } void dfs2(int n){ visited[n]=1; scc[upto].push_back(n); for (auto&i:g[n].in){ if (!visited[i]) dfs2(i); } } vector <int> find_split(int n,int a,int b,int c,vector <int> p,vector <int> q){ int m=p.size(); for (int i=0; i<m; i++){ g[p[i]].out.push_back(q[i]); g[q[i]].out.push_back(p[i]); g[p[i]].in.push_back(q[i]); g[q[i]].in.push_back(p[i]); } for (int i=0; i<n; i++){ if (!visited[i]) dfs1(i); } for (int i=0; i<n; i++) visited[i]=0; while (!st.empty()){ int t=st.top(); st.pop(); if (!visited[t]){ upto++; dfs2(t); } } vector <int> mas={}; int sz=0; for (int i=0; i<upto; i++){ if (scc[i].size()>sz){ sz=scc[i].size(); mas=scc[i]; } } vector <int> ans(n,0); if (b<=c){ if (sz>=b){ for (int i=0; i<b; i++) ans[mas[i]]=2; bool ff=1; for (int i=0; i,n; i++){ if (ans[i]) continue; if (ff){ ans[i]=1; ff=0; } else ans[i]=3; } } } else { if (sz>=c){ for (int i=0; i<c; i++) ans[mas[i]]=3; bool ff=1; for (int i=0; i<n; i++){ if (ans[i]) continue; if (ff){ ans[i]=1; ff=0; } else ans[i]=2; } } } return ans; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:48:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   if (scc[i].size()>sz){
      |       ~~~~~~~~~~~~~^~~
split.cpp:58:18: warning: left operand of comma operator has no effect [-Wunused-value]
   58 |    for (int i=0; i,n; 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...