Submission #953530

# Submission time Handle Problem Language Result Execution time Memory
953530 2024-03-26T05:33:52 Z yellowtoad Mechanical Doll (IOI18_doll) C++17
6 / 100
60 ms 13480 KB
#include "doll.h"
#include <iostream>
#include <vector>
using namespace std;

int n, m, s, cnt, idx;
vector<int> v[100010], xx, yy;

void create_circuit(int M, std::vector<int> a) {
  n = a.size(); m = M;
  vector<int> c(m+1), x, y;
  c[0] = a[0];
  a.push_back(0);
  for (int i = 0; i < n; i++) v[a[i]].push_back(a[i+1]);
  for (int i = 1; i <= m; i++) {
    if (v[i].empty()) c[i] = 0;
    else if (v[i].size() == 1) c[i] = v[i][0];
    else {
      xx.clear(); yy.clear();
      xx.push_back(0); yy.push_back(0);
      idx = 0;
      while ((1<<(idx+1)) < v[i].size()) {
        for (int j = 1; j <= (1<<idx); j++) {
          xx.push_back(s-xx.size()*2);
          yy.push_back(s-yy.size()*2+1);
        }
        idx++;
      }
      for (int j = 0; j < v[i].size()-1; j++) {
        if (j%2 == 0) xx.push_back(v[i][j]);
        else yy.push_back(v[i][j]);
      }
      for (int j = v[i].size(); j < (1<<(idx+1)); j++) {
        if (j%2 == 0) xx.push_back(s-1);
        else yy.push_back(s-1);
      }
      yy.push_back(v[i].back());
      c[i] = s-1;
      s -= (1<<(idx+1))-1;
      for (int i = 1; i < xx.size(); i++) {
        x.push_back(xx[i]);
        y.push_back(yy[i]);
      }
    }
  }
  /*for (int i = 0; i <= m; i++) cout << c[i] << " ";
  cout << endl;
  for (int i = 0; i < x.size(); i++) cout << x[i] << " ";
  cout << endl;
  for (int i = 0; i < y.size(); i++) cout << y[i] << " ";
  cout << endl;*/
  answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |       while ((1<<(idx+1)) < v[i].size()) {
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~
doll.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       for (int j = 0; j < v[i].size()-1; j++) {
      |                       ~~^~~~~~~~~~~~~~~
doll.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       for (int i = 1; i < xx.size(); i++) {
      |                       ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 15 ms 6488 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 15 ms 6488 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 41 ms 9508 KB Output is correct
9 Correct 34 ms 9860 KB Output is correct
10 Correct 51 ms 13480 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 18 ms 6740 KB Output is correct
3 Correct 15 ms 6488 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 27 ms 8404 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 41 ms 9508 KB Output is correct
9 Correct 34 ms 9860 KB Output is correct
10 Correct 51 ms 13480 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Incorrect 60 ms 12056 KB wrong serial number
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB wrong serial number
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2652 KB wrong motion
2 Halted 0 ms 0 KB -