제출 #632047

#제출 시각아이디문제언어결과실행 시간메모리
632047TimDee수천개의 섬 (IOI22_islands)C++17
10 / 100
35 ms9096 KiB
#include "islands.h"
#include <bits/stdc++.h>
using namespace std;

int n,m;
vector<int> u,v;

vector<int> vis(1e5+3,0);
vector<int> par(1e5+3,-1);
vector<vector<int>> adj(1e5+3);

variant<bool, std::vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {

  n=N,m=M,u=U,v=V;
  if (n==2) {
    vector<int> fv,sv;
    for (int x=0; x<m; ++x) if (u[x]==0) fv.push_back(x); else sv.push_back(x);
      int f=fv.size(), s=sv.size();
    if (f>=2 && s) {
      vector<int> r={fv[0],sv[0],fv[1],fv[0],sv[0],fv[1]};;
      return r;
    } 
    else return false;
  }

  if (n<=400 && m==n*(n-1)) {

    int a,b,c,d; 
    for (int i=0; i<m; ++i) {
      if (u[i]==0 && v[i]==1) a=i;
      if (u[i]==0 && v[i]==2) b=i;
      if (u[i]==1 && v[i]==0) c=i;
      if (u[i]==2 && v[i]==0) d=i;
    }
    vector<int> r = {a,c,b,d,c,a,d,b};
    return r;

  }

  int _p3=1, _p4=1;
  for (int i=0; i<m; i+=2) {
    _p3&=((u[i]==v[i+1])&&(v[i]==u[i+1]));
    _p4&=((u[i]==u[i+1])&&(v[i]==v[i+1]));
  }

  exit(0);

  if (_p3) {

    vector<int> deg(n,0);
    for (int i=0; i<m; i+=2) {
      deg[u[i]]++;
      deg[v[i]]++;
    }

    int mx=0;
    for (auto x:deg) mx=max(mx,x);
    if (mx<3) return false;

    vis[0]=1;
    queue<int> q; q.push(0);
    while (!q.empty()) {
      int x=q.front(); q.pop();
      if (deg[x]>=3) return true;
      for (auto y:adj[x]) {
        if (!vis[y]) {
          q.push(y);
          vis[y]=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:35:37: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     vector<int> r = {a,c,b,d,c,a,d,b};
      |                                     ^
islands.cpp:35:37: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:37: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
islands.cpp:35:37: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...