Submission #741349

#TimeUsernameProblemLanguageResultExecution timeMemory
741349josanneo22Painting Squares (IOI20_squares)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
typedef ll long long

vector<ll> ans;
void Init(){
    int k = 10;
	for (int i = 0; i < 10; i++) ans.push_back(1);
	int v = (1 << k) - 1;
	vector<bool> kt(1 << k);
	kt[v] = true;
	while ((int)ans.size() < 1000) {
		v = (v << 1) % (1 << k);
		int sign = 0;
		if (kt[v]) {
			v++;
			sign = 1;
		}
		kt[v] = true;
		ans.push_back(sign);
	}
}

#include "squares.h"
#include <vector>

std::vector<int> paint(int n) {
	std::vector<int> labels(n + 1, 1);
	if(ans.empty()) Init();
	ans[n]=10;
	for(int i=0;i<n;i++) labels[i]=ans[i];
	return labels;
}

int find_location(int n, std::vector<int> c) {
	if(ans.empty()) Init();
	vector<int> nw;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			if(i+j>=n) nw.pb(-1);
			else nw.pb(ans[i+j]);
		}
		if(nw==c) return i;
	}
}

Compilation message (stderr)

squares.cpp:9:9: error: 'll' does not name a type
    9 | typedef ll long long
      |         ^~
squares.cpp: In function 'void Init()':
squares.cpp:14:31: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |  for (int i = 0; i < 10; i++) ans.push_back(1);
      |                               ^~~
      |                               abs
squares.cpp:18:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |  while ((int)ans.size() < 1000) {
      |              ^~~
      |              abs
squares.cpp: In function 'std::vector<int> paint(int)':
squares.cpp:35:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |  if(ans.empty()) Init();
      |     ^~~
      |     abs
squares.cpp:36:2: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |  ans[n]=10;
      |  ^~~
      |  abs
squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:42:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |  if(ans.empty()) Init();
      |     ^~~
      |     abs
squares.cpp:47:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |    else nw.pb(ans[i+j]);
      |               ^~~
      |               abs
squares.cpp:43:14: warning: control reaches end of non-void function [-Wreturn-type]
   43 |  vector<int> nw;
      |              ^~