Submission #75056

# Submission time Handle Problem Language Result Execution time Memory
75056 2018-09-08T07:43:41 Z KieranHorgan Mechanical Doll (IOI18_doll) C++17
2 / 100
133 ms 18116 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

pair<int, int> exits[400005];
vector<int> C, X, Y;

vector<int> afterInList[400005];
int nextSwitchIdx = -1;

int build(int i, vector<int> cur) {
  if(cur.size() == 1) {
    return cur[0];
  }

  if(i >= 0) {
    return build(nextSwitchIdx--, cur);
  }

  if(X.size() < abs(i)) {
    X.resize(abs(i));
    Y.resize(abs(i));
  }

  vector<int> nextCur;
  for(int j = 0; j < cur.size(); j+=2)
    nextCur.push_back(cur[j]);
  X[-(i+1)] = build(nextSwitchIdx--, nextCur);

  nextCur.clear();
  for(int j = 1; j < cur.size(); j+=2)
    nextCur.push_back(cur[j]);
  Y[-(i+1)] = build(nextSwitchIdx--, nextCur);

  return i;
}

void create_circuit(int M, vector<int> A) {
  int N = A.size();
  C.assign(M+1, 0);

  afterInList[0].push_back(A[0]);
  for(int i = 0; i+1 < N; i++)
    afterInList[A[i]].push_back(A[i+1]);
  afterInList[A.back()].push_back(0);

  for(int i = 0; i <= M; i++) {
    if(afterInList[i].empty())
      continue;

    C[i] = build(i, afterInList[i]);
  }

  if(X.size() > 2*N) exit(-1);
  // cerr << N << " -> " << X.size() << endl;
  answer(C, X, Y);

}

Compilation message

doll.cpp: In function 'int build(int, std::vector<int>)':
doll.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int j = 0; j < cur.size(); j+=2)
      |                  ~~^~~~~~~~~~~~
doll.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int j = 1; j < cur.size(); j+=2)
      |                  ~~^~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:54:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |   if(X.size() > 2*N) exit(-1);
      |      ~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9572 KB Output is correct
2 Correct 49 ms 13380 KB Output is correct
3 Correct 48 ms 13048 KB Output is correct
4 Correct 8 ms 9676 KB Output is correct
5 Correct 23 ms 10828 KB Output is correct
6 Correct 67 ms 14700 KB Output is correct
7 Correct 8 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9572 KB Output is correct
2 Correct 49 ms 13380 KB Output is correct
3 Correct 48 ms 13048 KB Output is correct
4 Correct 8 ms 9676 KB Output is correct
5 Correct 23 ms 10828 KB Output is correct
6 Correct 67 ms 14700 KB Output is correct
7 Correct 8 ms 9676 KB Output is correct
8 Incorrect 133 ms 18116 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 9572 KB Output is correct
2 Correct 49 ms 13380 KB Output is correct
3 Correct 48 ms 13048 KB Output is correct
4 Correct 8 ms 9676 KB Output is correct
5 Correct 23 ms 10828 KB Output is correct
6 Correct 67 ms 14700 KB Output is correct
7 Correct 8 ms 9676 KB Output is correct
8 Incorrect 133 ms 18116 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 9676 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 9676 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 9676 KB state 'Y'
2 Halted 0 ms 0 KB -