답안 #103281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103281 2019-03-29T13:16:07 Z figter001 자동 인형 (IOI18_doll) C++17
37 / 100
181 ms 10072 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 2e5+50;

int n,cnt,at;
vector<int> x,y,a;
bool g[nax];

void dfs(int cur){
  if((at == a.size() - 1 && g[0] == 0) || at == a.size())
    return;
  int u = -cur;
  u--;
  if(x[u] == 0){
    x[u] = a[at];
    at++;
    dfs(-1);
  }else if(y[u] == 0){
    y[u] = a[at];
    at++;
    dfs(-1);
  }else if(g[u] == 0){
    g[u] = 1;
    dfs(x[u]);
  }else if(g[u] == 1){
    g[u] = 0;
    dfs(y[u]);
  }
}

void create_circuit(int M, vector<int> A) {
  a = A;
  if(A.size() % 2 == 0)
    a.push_back(0);
  a.push_back(0);
  n = a.size();
  if(n == 3){
    answer({1,0},{},{});
    return;
  }
  for(int k=0;k<30;k++){
    if((1<<k) >= n){
      cnt = (1<<k)-1;
      break;
    }
  }
  x.resize(cnt,0);
  y.resize(cnt,0);
  for(int i=0;i<cnt/2;i++){
    x[i] = -((i+1)*2);
    y[i] = -((i+1)*2+1);
  }
  vector<int> C(M+1,-1);
  dfs(-1);
  for(int i=0;i<cnt;i++){
    if(x[i] == 0){
      x[i] = -1;
    }
    if(y[i] == 0){
      y[i] = -1;
    }
    if(i == cnt-1)
      y[i] = 0;
  }
  answer(C, x, y);
}

Compilation message

doll.cpp: In function 'void dfs(int)':
doll.cpp:16:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   if((at == a.size() - 1 && g[0] == 0) || at == a.size())
      |       ~~~^~~~~~~~~~~~~~~
doll.cpp:16:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   if((at == a.size() - 1 && g[0] == 0) || at == a.size())
      |                                           ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 92 ms 8184 KB Output is partially correct
3 Partially correct 97 ms 8208 KB Output is partially correct
4 Partially correct 128 ms 8932 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 92 ms 8184 KB Output is partially correct
3 Partially correct 97 ms 8208 KB Output is partially correct
4 Partially correct 128 ms 8932 KB Output is partially correct
5 Partially correct 124 ms 10072 KB Output is partially correct
6 Partially correct 175 ms 9688 KB Output is partially correct
7 Partially correct 126 ms 9744 KB Output is partially correct
8 Partially correct 181 ms 9460 KB Output is partially correct
9 Partially correct 97 ms 8228 KB Output is partially correct
10 Partially correct 136 ms 9356 KB Output is partially correct
11 Partially correct 127 ms 9036 KB Output is partially correct
12 Partially correct 96 ms 8356 KB Output is partially correct
13 Partially correct 99 ms 8820 KB Output is partially correct
14 Partially correct 102 ms 8888 KB Output is partially correct
15 Partially correct 102 ms 8992 KB Output is partially correct
16 Partially correct 4 ms 588 KB Output is partially correct
17 Correct 70 ms 5820 KB Output is correct
18 Partially correct 103 ms 8476 KB Output is partially correct
19 Partially correct 102 ms 8396 KB Output is partially correct
20 Partially correct 162 ms 9216 KB Output is partially correct
21 Partially correct 123 ms 8988 KB Output is partially correct
22 Partially correct 120 ms 9048 KB Output is partially correct