제출 #1058108

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


std::variant<bool, std::vector<int>> find_journey(int N, int M, std::vector<int> U, std::vector<int> V) {
  if(N == 2){
    vector<int> c[2];
    for(int i = 0; i < M; i++){
        if(U[i] == 0) c[0].pb(i);
        else c[1].pb(i);
    }

    if(c[0].size() > 1 && c[1].size() > 0){
        int x = c[0][0], y = c[0][1], z = c[1][0];
        vector<int> ans = {x, z, y, x, z, y};
        return ans;
    }
    else return false;
  }

  if(N <= 400){
    vector<vector<int> > cnt(N, vector<int>(N, -1));
    for(int i = 0; i < M; i++){
        cnt[U[i]][V[i]] = i;
    }
    bool ok = 1;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            if(cnt[i][j] == -1) ok = 0;
        }
    }

    if(ok){ // subtask 2
        int c0 = cnt[0][1];
        int c1 = cnt[1][2];
        int c2 = cnt[2][0];

        int c3 = cnt[0][2];
        int c4 = cnt[2][1];
        int c5 = cnt[1][0];

        vector<int> ans = {c0, c1, c2, c3, c4, c5, c2, c1, c0, c5, c4, c3};
        return ans;
    }
  }


  return false;
}
/*
int main() {
  int N, M;
  assert(2 == scanf("%d %d", &N, &M));

  std::vector<int> U(M), V(M);
  for (int i = 0; i < M; ++i) {
    assert(2 == scanf("%d %d", &U[i], &V[i]));
  }

  std::variant<bool, std::vector<int>> result = find_journey(N, M, U, V);
  if (result.index() == 0) {
    printf("0\n");
    if (std::get<bool>(result)) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  } else {
    printf("1\n");
    std::vector<int> &canoes = std::get<std::vector<int>>(result);
    printf("%d\n", static_cast<int>(canoes.size()));
    for (int i = 0; i < static_cast<int>(canoes.size()); ++i) {
      if (i > 0) {
        printf(" ");
      }
      printf("%d", canoes[i]);
    }
    printf("\n");
  }
  return 0;
}
*/
#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...