제출 #1014789

#제출 시각아이디문제언어결과실행 시간메모리
1014789alex_2008Split the Attractions (IOI19_split)C++14
0 / 100
1093 ms1048576 KiB
#include "split.h" #include <iostream> #include <cmath> #include <vector> #include <set> #include <map> #include <algorithm> #include <queue> using namespace std; typedef long long ll; const int N = 1e5 + 10, M = 110; vector <vector<int>> G; vector<int> find_split(int n, int A, int B, int C, vector<int> p, vector<int> q) { int m = (int)p.size(); bool sb1 = true, sb2 = true; G.resize(n); for (int i = 0; i < m; i++) { G[p[i]].push_back(q[i]); G[q[i]].push_back(p[i]); } for (int i = 0; i < n; i++) { if ((int)G[i].size() > 2) sb1 = false; } if (sb1) { int a = -1, b = -1; for (int i = 0; i < n; i++) { if ((int)G[i].size() == 1) { if (a == -1) a = i; else b = i; } } vector <int> v; if (a != -1) { v.push_back(a); v.push_back(G[a][0]); while (v.back() != b) { int a = v[(int)v.size() - 1]; int b = v[(int)v.size() - 2]; if (G[a][0] == b) v.push_back(G[a][1]); else v.push_back(G[a][0]); } } else { v.push_back(a); v.push_back(G[a][0]); while (v.size() != n) { int last = v.back(); if (G[last][0] != v[(int)v.size() - 2]) v.push_back(G[last][0]); else v.push_back(G[last][1]); } } vector <int> ans(n); for (int i = 0; i < n; i++) { if (i < A) ans[v[i]] = 1; else if (i < A + B) ans[v[i]] = 2; else ans[v[i]] = 3; } return ans; } } /*int main() { }*/

컴파일 시 표준 에러 (stderr) 메시지

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |    while (v.size() != n) {
      |           ~~~~~~~~~^~~~
split.cpp:15:19: warning: unused variable 'sb2' [-Wunused-variable]
   15 |  bool sb1 = true, sb2 = true;
      |                   ^~~
split.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
#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...