답안 #75052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75052 2018-09-08T06:53:06 Z KieranHorgan 자동 인형 (IOI18_doll) C++17
0 / 100
2 ms 256 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

pair<int, int> exits[400005];
vector<int> X, Y;
int nodeIdx = 1;
void build(vector<int> cur) {
  int curNode = nodeIdx++;
  if(cur.size() == 1) {
    if(cur[0] < 0) {
      exits[curNode] = {-cur[0], 0};
      return;
    }
    exits[curNode] = {cur[0], -1};
    return;
  }

  vector<int> nextCur;
  for(int i = 0; i < cur.size(); i+=2) {
    nextCur.push_back(cur[i]);
  }
  build(nextCur);
  nextCur.clear();

  exits[curNode] = {-(curNode+1), -(nodeIdx)};
  for(int i = 1; i < cur.size(); i+=2) {
    nextCur.push_back(cur[i]);
  }
  build(nextCur);
  nextCur.clear();
}

void create_circuit(int M, vector<int> A) {
  int N = A.size();
  vector<int> C(M + 1);
  C[0] = -1;
  for (int i = 1; i <= M; ++i) {
    C[i] = -1;
  }

  vector<int> cur;
  for(int i = 0; i < A.size(); i++) {
    cur.push_back(A[i]);
  }
  cur.back() = -cur.back();

  build(cur);

  for(int i = 1; i < nodeIdx; i++) {
    X.push_back(exits[i].first);
    Y.push_back(exits[i].second);
    cerr << i << ": " << X.back() << " " << Y.back() << endl;
  }
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void build(std::vector<int>)':
doll.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i = 0; i < cur.size(); i+=2) {
      |                  ~~^~~~~~~~~~~~
doll.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i = 1; i < cur.size(); i+=2) {
      |                  ~~^~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i = 0; i < A.size(); i++) {
      |                  ~~^~~~~~~~~~
doll.cpp:35:7: warning: unused variable 'N' [-Wunused-variable]
   35 |   int N = A.size();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -