Submission #766075

# Submission time Handle Problem Language Result Execution time Memory
766075 2023-06-25T09:50:39 Z ono_de206 Mechanical Doll (IOI18_doll) C++14
Compilation error
0 ms 0 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void create_circuit(int m, std::vector<int> a) {
	int n = a.size();
	a.pb(0);
	vector<int> C(m + 1, 0), X, Y;
	vector<vector<int>> nx(m + 1);
	nx[0].pb(a[0]);
	for(int i = 0; i < n; i++) {
		nx[a[i]].pb(a[i + 1]);
	}
	int now = 0, root;

	function<int(vector<int>&)> solve = [&](vector<int>& vec) {
		if(vec.size() == 2) {
			X.pb(vec[0]);
			Y.pb(vec[1]);
		} else {
			vector<int> first, second;
			for(int i = 0; i < vec.size(); i += 2) {
				first.pb(vec[i]);
				second.pb(vec[i + 1]);
			}
			X.pb(solve(first));
			Y.pb(solve(second));
		}
		node++;
		return -node;
	};

	for(int i = 0; i <= m; i++) {
		if(nx[i].size() == 0) continue;
		if(nx[i].size() == 1) {
			C[i] = nx[i][0];
			continue;
		}
		int nxt = 1;
		while(nxt * 2 < nx[i].size()) nxt *= 2;
		reverse(all(nx[i]));
		while(nx[i].size() < nxt) nx[i].pb(i);
		reverse(all(nx[i]));
		C[i] = solve(nx[i]);
	}
	answer(C, X, Y);
}

Compilation message

doll.cpp: In lambda function:
doll.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int i = 0; i < vec.size(); i += 2) {
      |                   ~~^~~~~~~~~~~~
doll.cpp:45:3: error: 'node' was not declared in this scope
   45 |   node++;
      |   ^~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:47:2: error: conversion from 'create_circuit(int, std::vector<int>)::<lambda(std::vector<int>&)>' to non-scalar type 'std::function<int(std::vector<int>&)>' requested
   47 |  };
      |  ^
doll.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   while(nxt * 2 < nx[i].size()) nxt *= 2;
      |         ~~~~~~~~^~~~~~~~~~~~~~
doll.cpp:58:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   while(nx[i].size() < nxt) nx[i].pb(i);
      |         ~~~~~~~~~~~~~^~~~~
doll.cpp:30:6: warning: unused variable 'now' [-Wunused-variable]
   30 |  int now = 0, root;
      |      ^~~
doll.cpp:30:15: warning: unused variable 'root' [-Wunused-variable]
   30 |  int now = 0, root;
      |               ^~~~