제출 #381926

#제출 시각아이디문제언어결과실행 시간메모리
381926IwanttobreakfreePainting Squares (IOI20_squares)C++17
컴파일 에러
0 ms0 KiB
#include "squares.h" #include <vector> using namespace std; vector<int> guardado; vector<int> paint(int n) { guardado.clear(); vector<int> potencias(10); potencias[9]=1; for(int i=8;i>=0;i--)potencias[i]=potencias[i+1]*2; int num=1; int cont=0; while(labels.size()!=n){ if(num>=potencias[cont]){ num-=potencias[cont]; labels.push_back(1); guardado.push_back(1); } else{ labels.push_back(0); guardado.push_back(0); } cont++; if(cont==10){ num+=2; cont=0; } } labels.push_back(30); return labels; } int find_location(int n, vector<int> c) { bool posi; for(int i=0;i<guardado.size()-n;i++){ posi=true; for(int j=0;j<n;j++){ if(c[j]==-1){ int tot=guardado.size(); return tot-n+j; } if(guardado[i+j]!=c[j]){ pos=false; break; } } if(posi)return i; } }

컴파일 시 표준 에러 (stderr) 메시지

squares.cpp: In function 'std::vector<int> paint(int)':
squares.cpp:12:8: error: 'labels' was not declared in this scope
   12 |  while(labels.size()!=n){
      |        ^~~~~~
squares.cpp:28:2: error: 'labels' was not declared in this scope
   28 |  labels.push_back(30);
      |  ^~~~~~
squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i=0;i<guardado.size()-n;i++){
      |              ~^~~~~~~~~~~~~~~~~~
squares.cpp:42:5: error: 'pos' was not declared in this scope; did you mean 'posi'?
   42 |     pos=false;
      |     ^~~
      |     posi
squares.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^