Submission #418500

#TimeUsernameProblemLanguageResultExecution timeMemory
418500EncryptingWolfMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include <vector>
#include <iostream>
#include <queue>
#include <algorithm>
typedef long long ll;
#define FOR(i,x,y) for (ll i = x; i<y; i++)
using namespace std;



void create_circuit(int M, vector<int> A)
{
	A.push_back(0);
	M += 1;
	vector<int> connections(M);
	connections[0] = A[0];
	vector<pair<int,int>> switches;
	vector<vector<int>> follow(M);
	FOR(i, 0, A.size() - 1)
	{
		follow[A[i]].push_back(A[i + 1]);
	}
	int lowestSwitch = -1;
	FOR(i,1,M)
	{
		if (follow[i].size() == 1)
		{
			connections[i]=follow[i][0];
		}
		else
		{
			connections[i] = lowestSwitch;
			lowestSwitch--;
			int switchStart = lowestSwitch;
			int num = 1;
			while (num*2 < follow[i].size())
			{
				int firstSwitch = switches.size() - num;
				FOR(j, firstSwitch, firstSwitch+num)
				{
					switches[j].first = lowestSwitch;
					switches[j].second = lowestSwitch-1;
					lowestSwitch -= 2;
					switches.push_back({});
					switches.push_back({});
				}
				num *= 2;
			}

			int firstSwitch = switches.size() - num;
			int outnum = num * 2;
			int z = 0;
			FOR(j, (firstSwitch*2), (firstSwitch + num)*2)
			{
				if (outnum > follow[i].size())
				{
					if (j % 2 == 0)
					{
						switches[j / 2].first = switchStart;
					}
					if (j % 2 == 1)
					{
						switches[j / 2].second = switchStart;
					}
				}
				else
				{
					if (j % 2 == 0)
					{
						switches[j / 2].first = follow[i][z];
					}
					if (j % 2 == 1)
					{
						switches[j / 2].second = follow[i][z];
					}
					z++;
				}
			}
		}
	}
	vector<int> X, Y;
	FOR(i, 0, switches.size())
	{
		X.push_back(switches[i].first);
		Y.push_back(switches[i].second);
	}
	answer(connections, X, Y);

}

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:6:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i,x,y) for (ll i = x; i<y; i++)
......
   19 |  FOR(i, 0, A.size() - 1)
      |      ~~~~~~~~~~~~~~~~~~             
doll.cpp:19:2: note: in expansion of macro 'FOR'
   19 |  FOR(i, 0, A.size() - 1)
      |  ^~~
doll.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    while (num*2 < follow[i].size())
      |           ~~~~~~^~~~~~~~~~~~~~~~~~
doll.cpp:55:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if (outnum > follow[i].size())
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~
doll.cpp:6:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define FOR(i,x,y) for (ll i = x; i<y; i++)
......
   82 |  FOR(i, 0, switches.size())
      |      ~~~~~~~~~~~~~~~~~~~~~          
doll.cpp:82:2: note: in expansion of macro 'FOR'
   82 |  FOR(i, 0, switches.size())
      |  ^~~
doll.cpp:87:2: error: 'answer' was not declared in this scope
   87 |  answer(connections, X, Y);
      |  ^~~~~~