Submission #434199

#TimeUsernameProblemLanguageResultExecution timeMemory
434199TLP39Painting Squares (IOI20_squares)C++14
Compilation error
0 ms0 KiB
#include "squares.h"
#include <bits/stdc++.h>

vector<int> adj[512];

void init_adj()
{
	for(int i=0;i<512;i++)
	{
	adj[i].clear();	
		adj[i].push_back((i<<1)%512);
		adj[i].push_back((i<<1)%512+1);
}
}

vector<int> cyc;
stack<int> path;
int appear[1024];
vector<int> labels;
void get_cycle()
{
	cyc.clear();
	path.push(0);
	int temp;
	while(!path.empty())
	{
		if(adj[path.top()].size())
		{
			temp=adj[path.top()][adj[path.top()].size()-1];
			adj[path.top()].pop_back();
			path.push(temp);
		}
		else
		{
			cyc.push_back(path.top());
			path.pop();
		}
	}
	for(int i=0;i<9;i++) labels.push(0);
	for(int i=0;i<1024;i++)
	{
		appear[cyc[cyc.size()-1]+(cyc[cyc.size()-2]&1)]=i;
		cyc.pop_back();
		labels.push(cyc[cyc.size()-1]&1);
}
}

vector<int> paint(int n) {
	labels.clear();
	init_adj();
get_cycle();
while(labels.size()>n) labels.pop_back();
labels.push_back(10);
	return labels;
}

int find_location(int n, std::vector<int> c) {
	if(c[9]==-1)
	{
		for(int i=0;i<=9;i++) if(c[i]==-1) return n-i;
		return -1;
	}
	int code=0;
	for(int i=0;i<=9;i++)
	{
		code+=c[i]<<(9-i);
	}
	return appear[code];
}

Compilation message (stderr)

squares.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> adj[512];
      | ^~~~~~
squares.cpp: In function 'void init_adj()':
squares.cpp:10:2: error: 'adj' was not declared in this scope
   10 |  adj[i].clear();
      |  ^~~
squares.cpp: At global scope:
squares.cpp:16:1: error: 'vector' does not name a type
   16 | vector<int> cyc;
      | ^~~~~~
squares.cpp:17:1: error: 'stack' does not name a type; did you mean 'obstack'?
   17 | stack<int> path;
      | ^~~~~
      | obstack
squares.cpp:19:1: error: 'vector' does not name a type
   19 | vector<int> labels;
      | ^~~~~~
squares.cpp: In function 'void get_cycle()':
squares.cpp:22:2: error: 'cyc' was not declared in this scope
   22 |  cyc.clear();
      |  ^~~
squares.cpp:23:2: error: 'path' was not declared in this scope
   23 |  path.push(0);
      |  ^~~~
squares.cpp:27:6: error: 'adj' was not declared in this scope
   27 |   if(adj[path.top()].size())
      |      ^~~
squares.cpp:39:23: error: 'labels' was not declared in this scope; did you mean 'labs'?
   39 |  for(int i=0;i<9;i++) labels.push(0);
      |                       ^~~~~~
      |                       labs
squares.cpp:44:3: error: 'labels' was not declared in this scope; did you mean 'labs'?
   44 |   labels.push(cyc[cyc.size()-1]&1);
      |   ^~~~~~
      |   labs
squares.cpp: At global scope:
squares.cpp:48:1: error: 'vector' does not name a type
   48 | vector<int> paint(int n) {
      | ^~~~~~