Submission #430421

#TimeUsernameProblemLanguageResultExecution timeMemory
430421schsePainting Squares (IOI20_squares)C++17
Compilation error
0 ms0 KiB
#include "squares.h" #include <vector> #ifndef EVAL #include "grader.cpp" #endif #include <bits/stdc++.h> using namespace std; bool seen[1024 + 10]; vector<int> edges; int pos[1024]; vector<int> debj; void dfs(int node) { for (int i = 0; i < 2; i++) { int cn = node * 2 + i; if (!seen[cn]) { seen[cn] = true; dfs(cn & 511); edges.push_back(i); } } } vector<int> deBruijn() { fill(seen, seen + 1024, 0); edges.clear(); dfs(0); for (int i = 0; i < 10; i++) edges.push_back(0); vector<int> v; for (int i = 0; i < edges.size() - 10; i++) { int c = 0; for (int e = 0; e < 10; e++) { c = c * 2 + edges[i + e]; } pos[c] = i; } for (int i = 0; i < n; i++) v.push_back(edges[i]); v.push_back(10); return v; } std::vector<int> paint(int n) { return deBruijn(); } int find_location(int n, std::vector<int> c) { if (c.back() == -1) { int p = n - c.size(); while (c.back() == -1) { p++; c.pop_back(); } return p; } int b = 0; for (int i = 0; i < c.size(); i++) { b = b * 2 + c[i]; } return pos[b]; }

Compilation message (stderr)

squares.cpp: In function 'std::vector<int> deBruijn()':
squares.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for (int i = 0; i < edges.size() - 10; i++)
      |                  ~~^~~~~~~~~~~~~~~~~~~
squares.cpp:48:22: error: 'n' was not declared in this scope
   48 |  for (int i = 0; i < n; i++)
      |                      ^
squares.cpp:48:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   48 |  for (int i = 0; i < n; i++)
      |  ^~~
squares.cpp:50:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |   v.push_back(10);
      |   ^
squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:72:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |  for (int i = 0; i < c.size(); i++)
      |                  ~~^~~~~~~~~~