제출 #1239684

#제출 시각아이디문제언어결과실행 시간메모리
1239684AlperenT_수천개의 섬 (IOI22_islands)C++20
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <variant> #include <vector> #include <bits/stdc++.h> //#include "segments.h" #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #define pb push_back #define F first #define pii pair<int,int> #define all(a) a.begin(),a.end() #define S second #define sz(a) (int)a.size() #define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++) #define per(i , a , b) for(int i = (a) ; i >= (b) ; i--) #define ld double #define ll long long using namespace std ; const int maxn = 1e6 + 10 , inf = 1e9+ 10 , mod = 998244353; int mark[maxn] ; vector <pii> G[maxn] ; std::variant<bool, std::vector<int>> find_journey(int n, int m, std::vector<int> U, std::vector<int> V) { rep(i , 0 ,m-1){ G[U[i]].pb({V[i] , i}); } bool ok =0; vector <int> vec ; if(sz(G[0]) >= 2)return 1 ; if(sz(G[0]) == 0)return 0 ; int v =G[v][0].F ; mark[0] = 1; while(1){ int nx = -1; mark[v] = 1; for(auto [u,w] : G[V]){ if(nx!=-1 && mark[u] == 0)return 1 ; if(mark[u] == 0)nx = u ; } v = nx ; if(nx == -1)return 0 ; } return 1; }

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

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:29:27: error: could not convert '1' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   29 |   if(sz(G[0]) >= 2)return 1 ;
      |                           ^
      |                           |
      |                           int
islands.cpp:30:27: error: could not convert '0' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   30 |   if(sz(G[0]) == 0)return 0  ;
      |                           ^
      |                           |
      |                           int
islands.cpp:36:23: error: no match for 'operator[]' (operand types are 'std::vector<std::pair<int, int> > [1000010]' and 'std::vector<int>')
   36 |     for(auto [u,w] : G[V]){
      |                       ^
islands.cpp:37:40: error: could not convert '1' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   37 |       if(nx!=-1 && mark[u] == 0)return 1 ;
      |                                        ^
      |                                        |
      |                                        int
islands.cpp:41:24: error: could not convert '0' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   41 |     if(nx == -1)return 0 ;
      |                        ^
      |                        |
      |                        int
islands.cpp:43:10: error: could not convert '1' from 'int' to 'std::variant<bool, std::vector<int, std::allocator<int> > >'
   43 |   return 1;
      |          ^
      |          |
      |          int