Submission #418256

#TimeUsernameProblemLanguageResultExecution timeMemory
418256FlippenFazMechanical Doll (IOI18_doll)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> c; vector<int> x; vector<int> y; vector<vector<int>> cons; void connect(int start, int end) { if (c[start] == 0) { c[start] = end; } else if (c[start] > 0) { x.push_back( c[start] ); y.push_back( end ); c[start] = -x.size(); } else { } } void create_circuit(int m, vector<int> a) { cons.resize(m+1); c.resize(m+1); int prev = 0; for (int i = 0; i < a.size(); i++) { cons[prev].push_back(a[i]); prev = a[i]; } for (int i = 0; i < cons.size(); i++) { //cout << "I IS: " << i << endl; //cout << "CON SIZE IS: " << cons[i].size() << endl; if (cons[i].size() == 0) { c[i] = 0; } else if (cons[i].size() == 1) { c[i] = cons[i][0]; } else { cout << "CUR I: " << i; int offset = -x.size(); c[i] = offset - 1; int added = pow(2,ceil(log2(cons[i].size()))) - 1; //cout << "ADDED: " << added; for (int j = 1; j < added+1; j++) { x.push_back( offset -j*2 ); y.push_back( offset -j*2 - 1); } //cout << "HERE" << endl; int last = added/2+1; int start = x.size()-last; int cnt = 0; for (int j = start; j < x.size(); j++) { x[j] = -j-1; y[j] = cons[i][cnt++]; } for (int j = start; cnt < cons[i].size(); j++) { x[j] = y[j]; y[j] = cons[i][cnt++]; } } } cout << x.size() << endl; for (int i = 0; i < c.size(); i++) { cout << c[i] << endl; } for (int i = 0; i < x.size(); i++) { cout << x[i] << " " << y[i] << endl; } } int M, N; int temp; vector<int> inp; int main() { cin >> M >> N; for (int i = 0; i < N; i++) { cin >> temp; inp.push_back(temp); } create_circuit(M, inp); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
doll.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < cons.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
doll.cpp:58:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for (int j = start; j < x.size(); j++) {
      |                                 ~~^~~~~~~~~~
doll.cpp:62:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for (int j = start; cnt < cons[i].size(); j++) {
      |                                 ~~~~^~~~~~~~~~~~~~~~
doll.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for (int i = 0; i < c.size(); i++) {
      |                     ~~^~~~~~~~~~
doll.cpp:74:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |     for (int i = 0; i < x.size(); i++) {
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccjuPiWO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3apF3P.o:doll.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status