Submission #1207640

#TimeUsernameProblemLanguageResultExecution timeMemory
1207640raphaelpMechanical Doll (IOI18_doll)C++20
Compilation error
0 ms0 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; int rev(int x) { int ans = 0; while (x) { ans *= 2; ans += x % 2; x /= 2; } return ans; } void create_circuit(int M, vector<int> A) { int N = A.size(); vector<vector<int>> exits(M + 1); exits[0].push_back(A[0]); for (int i = 0; i < N - 1; i++) exits[A[i]].push_back(A[i + 1]); exits[A.back()].push_back(0); vector<int> X, Y, C(M + 1); for (int i = 0; i <= M; i++) { int last = X.size(); int x = exits[i].size(); if (x == 0) { C[i] = 0; continue; } C[i] = exits[i][0]; if (x == 1) continue; C[i] = -last - 1; for (int j = 0; j < x - 1; j++) { X.push_back(M + 1); Y.push_back(M + 1); if (j * 2 + 1 < x - 1) X[j] = -(last + j * 2 + 1) - 1; else X[j] = exits[i][rev(j)]; if (j * 2 + 2 < x - 1) Y[j] = -(last + j * 2 + 2) - 1; else Y[j] = exits[i][rev(2 * j + 1)]; } } return (C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:51:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
   51 |     return (C, X, Y);
      |            ~~~~~^~~~