제출 #846119

#제출 시각아이디문제언어결과실행 시간메모리
846119math_rabbit_1028가장 긴 여행 (IOI23_longesttrip)C++17
30 / 100
807 ms2132 KiB
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; int n; vector<int> adj[256]; vector<int> res; vector<int> longest_trip(int N, int D) { n = N; res.clear(); for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (are_connected({i}, {j})) { adj[i].push_back(j); adj[j].push_back(i); } } } res.push_back(0); while (true) { int bef = res.size(); for (int i = 0; i < adj[res.back()].size(); i++) { int v = adj[res.back()][i]; bool f = false; for (int j = 0; j < res.size(); j++) { if (res[j] == v) f = true; } if (f) continue; res.push_back(v); break; } if (bef == res.size()) break; } for (int i = 0; i < adj[res.back()].size(); i++) { int v = adj[res.back()][i]; bool f = false; for (int j = 0; j < res.size(); j++) { if (res[j] == v) f = true; } if (f) continue; res.insert(res.begin(), v); break; } if (res.size() >= n - res.size()) { return res; } vector<int> temp; for (int i = 0; i < n; i++) { bool f = false; for (int j = 0; j < res.size(); j++) { if (res[j] == i) f = true; } if (f) continue; temp.push_back(i); } return temp; }

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

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < adj[res.back()].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~
longesttrip.cpp:28:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for (int j = 0; j < res.size(); j++) {
      |                             ~~^~~~~~~~~~~~
longesttrip.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (bef == res.size()) break;
      |             ~~~~^~~~~~~~~~~~~
longesttrip.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < adj[res.back()].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~
longesttrip.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int j = 0; j < res.size(); j++) {
      |                         ~~^~~~~~~~~~~~
longesttrip.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for (int j = 0; j < res.size(); j++) {
      |                         ~~^~~~~~~~~~~~
#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...