제출 #1009267

#제출 시각아이디문제언어결과실행 시간메모리
1009267boris_mihovSimurgh (IOI17_simurgh)C++17
0 / 100
2 ms2648 KiB
#include "simurgh.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <cstring> #include <vector> typedef long long llong; const int MAXN = 500 + 12; int idx[MAXN][MAXN]; bool isIn[MAXN][MAXN]; std::vector <int> find_roads(int n, std::vector <int> u, std::vector <int> v) { memset(idx, -1, sizeof(idx)); for (int i = 0 ; i < u.size() ; ++i) { idx[u[i]][v[i]] = i; idx[v[i]][u[i]] = i; } int res = MAXN; std::vector <int> answers; for (int i = 1 ; i < n ; ++i) { std::vector <int> tree; for (int j = 1 ; j + 1 < n ; ++j) { tree.push_back(idx[j][j + 1]); } tree.push_back(idx[0][i]); answers.push_back(count_common_roads(tree)); res = std::min(res, answers.back()); } int cntGlobalOnes = 0; for (int i = 0 ; i < n - 1 ; ++i) { isIn[0][i + 1] = (answers[i] > res); cntGlobalOnes += isIn[0][i + 1]; } for (int u = 1 ; u < n ; ++u) { int cntCurrentOnes = 0; std::vector <int> newTree; for (int i = 1 ; i <= u ; ++i) { cntCurrentOnes += isIn[0][i]; newTree.push_back(idx[0][i]); } for (int i = u + 1 ; i < n ; ++i) { newTree.push_back(idx[u][i]); } int currentlyFound = 0; int lastOne = u; int toBeFound = (count_common_roads(newTree) - cntCurrentOnes); while (toBeFound--) { int l = lastOne, r = n, mid; while (l < r - 1) { mid = (l + r) >> 1; std::vector <int> currentTree; int binaryOnes = 0; for (int i = 1 ; i <= u ; ++i) { currentTree.push_back(idx[0][i]); binaryOnes += idx[0][i]; } for (int i = u + 1 ; i <= mid ; ++i) { currentTree.push_back(idx[u][i]); } for (int i = mid + 1 ; i < n ; ++i) { currentTree.push_back(idx[0][i]); binaryOnes += idx[0][i]; } int ones = count_common_roads(currentTree) - binaryOnes; if (ones <= currentlyFound) l = mid; else r = mid; } assert(r < n); isIn[u][r] = true; lastOne = r; } } std::vector <int> sol; for (int i = 0 ; i < n ; ++i) { for (int j = i + 1 ; j < n ; ++j) { if (isIn[i][j]) { sol.push_back(idx[i][j]); } } } return sol; }

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

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:17:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0 ; i < u.size() ; ++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...