제출 #1051216

#제출 시각아이디문제언어결과실행 시간메모리
1051216Trent수천개의 섬 (IOI22_islands)C++17
8.40 / 100
22 ms6116 KiB
#include "islands.h" #include "bits/stdc++.h" using namespace std; #define forR(i, x) for(int i = 0; i < (x); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define all(x) x.begin(), x.end() typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; typedef vector<bool> vb; struct edge{int t, i;}; vector<vector<edge>> adj; vi nStk, eStk; vb oStk, vis; bool dfs(int c, vi& ans) { // nStk is [0, c), eStk is [0, c] if(oStk[c]) { int sInd; forR(i, nStk.size()) if(nStk[i] == c) sInd = i; forR(i, sInd) ans.push_back(eStk[i]); REP(i, sInd, eStk.size()) ans.push_back(eStk[i]); REP(i, sInd, eStk.size()) ans.push_back(eStk[i] ^ 1); REP(i, sInd, eStk.size()) ans.push_back(eStk[i]); REP(i, sInd, eStk.size()) ans.push_back(eStk[i] ^ 1); for(int i = sInd - 1; i >= 0; --i) ans.push_back(eStk[i]); return true; } if(!vis[c]) { vis[c] = true; oStk[c] = true; nStk.push_back(c); for(auto [t, i] : adj[c]) { eStk.push_back(i); if(dfs(t, ans)) return true; eStk.pop_back(); } nStk.pop_back(); oStk[c] = false; } return false; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { adj.resize(N); forR(i, M) { adj[U[i]].push_back({V[i], i}); } oStk.resize(N); vis.resize(N); vi ans; bool done = dfs(0, ans); if(done) return ans; return false; }

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

islands.cpp: In function 'bool dfs(int, vi&)':
islands.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
islands.cpp:21:5: note: in expansion of macro 'forR'
   21 |     forR(i, nStk.size()) if(nStk[i] == c) sInd = i;
      |     ^~~~
islands.cpp:5:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define REP(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
islands.cpp:23:5: note: in expansion of macro 'REP'
   23 |     REP(i, sInd, eStk.size()) ans.push_back(eStk[i]);
      |     ^~~
islands.cpp:5:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define REP(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
islands.cpp:24:5: note: in expansion of macro 'REP'
   24 |     REP(i, sInd, eStk.size()) ans.push_back(eStk[i] ^ 1);
      |     ^~~
islands.cpp:5:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define REP(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
islands.cpp:25:5: note: in expansion of macro 'REP'
   25 |     REP(i, sInd, eStk.size()) ans.push_back(eStk[i]);
      |     ^~~
islands.cpp:5:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define REP(i, a, b) for(int i = (a); i < (b); ++i)
      |                                         ^
islands.cpp:26:5: note: in expansion of macro 'REP'
   26 |     REP(i, sInd, eStk.size()) ans.push_back(eStk[i] ^ 1);
      |     ^~~
islands.cpp:20:9: warning: 'sInd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     int sInd;
      |         ^~~~
#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...