답안 #601503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601503 2022-07-22T06:18:16 Z Belgutei 자동 인형 (IOI18_doll) C++17
6 / 100
73 ms 12092 KB
#include "doll.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define mk make_pair
#define pb push_back

vector<int> v[100005];

int pos, level, tot,i;
int cnt = 0;
vector<int> X, Y, c;
bool ok = 0;

void dfs(int k, int x) {
  if(k == level) {
    if(k == 1) {
      cnt --;
      c[i] = cnt;
    }
    if(pos < v[i].size()) {
      X.pb(v[i][pos]);
      pos ++;
      if(pos < v[i].size()) {
        Y.pb(v[i][pos]);
        pos ++;
      }
      else Y.pb(0);
    }
    else {
      X.pb(0);
      Y.pb(0);
    }
  }
  if(k != level){
    cnt --;
    if(k == 1 && x == 0) c[i] = cnt;
    X.pb(cnt);
    dfs(k + 1, x * 2);
    //
    cnt --;
    Y.pb(cnt);
    //
    dfs(k + 1, x * 2 + 1);
    return;
  }
}

void create_circuit(int M, std::vector<int> A) {
  v[0].pb(A[0]);
  for(i = 0; i < A.size(); i ++) {
    if(i == A.size() - 1) {
      v[A[i]].pb(0);
    }
    else {
      v[A[i]].pb(A[i + 1]);
    }
  }
  c.resize(M + 1);
  //
  for(i = 0; i <= M; i ++) {
    if(v[i].size() == 0) continue;
    if(v[i].size() == 1) {
      c[i] = v[i][0];
      continue;
    }
    for(int j = 1; j <= 20; j ++) {
      if((1 << j) >= v[i].size()) {level = j; break;}
    }
    tot = v[i].size();
    pos = 0;
    ok = 0;
    dfs(1,0);
  }
  //
  // for(auto x: c) cout << x << ' ';
  // cout << '\n';
  // for(auto x: X) cout << x << ' ' ;
  // cout << '\n';
  // for(auto x: Y) cout << x << ' ' ;
  // cout << '\n';
  //
  answer(c,X,Y);
  //
  // int N = A.size();
  // std::vector<int> C(M + 1);
  // C[0] = -1;
  // for (int i = 1; i <= M; ++i) {
  //   C[i] = 1;
  // }
  // std::vector<int> X(N), Y(N);
  // for (int k = 0; k < N; ++k) {
  //   X[k] = Y[k] = A[k];
  // }
  // answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void dfs(int, int)':
doll.cpp:25:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if(pos < v[i].size()) {
      |        ~~~~^~~~~~~~~~~~~
doll.cpp:28:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |       if(pos < v[i].size()) {
      |          ~~~~^~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:55:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for(i = 0; i < A.size(); i ++) {
      |              ~~^~~~~~~~~~
doll.cpp:56:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     if(i == A.size() - 1) {
      |        ~~^~~~~~~~~~~~~~~
doll.cpp:72:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |       if((1 << j) >= v[i].size()) {level = j; break;}
      |          ~~~~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 23 ms 6356 KB Output is correct
3 Correct 20 ms 5992 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 11 ms 3796 KB Output is correct
6 Correct 27 ms 7660 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 23 ms 6356 KB Output is correct
3 Correct 20 ms 5992 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 11 ms 3796 KB Output is correct
6 Correct 27 ms 7660 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 44 ms 8124 KB Output is correct
9 Correct 44 ms 8640 KB Output is correct
10 Correct 64 ms 11028 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 23 ms 6356 KB Output is correct
3 Correct 20 ms 5992 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 11 ms 3796 KB Output is correct
6 Correct 27 ms 7660 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 44 ms 8124 KB Output is correct
9 Correct 44 ms 8640 KB Output is correct
10 Correct 64 ms 11028 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Incorrect 73 ms 12092 KB wrong motion
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB wrong motion
2 Halted 0 ms 0 KB -