Submission #380957

#TimeUsernameProblemLanguageResultExecution timeMemory
380957BlancaHMPainting Squares (IOI20_squares)C++14
0 / 100
4 ms724 KiB
#include <iostream> #include <vector> #include <unordered_set> using namespace std; vector<int> squares; vector<int> paint(int n) { squares = vector<int>(n+1); squares[n] = 10; unordered_set<string> used; string window = "1111111111"; for (int i = 0; i < 10; i++) { if (i == n) break; squares[i] = 1; } used.insert(window); for (int i = 10; i < n; i++) { window.erase(0, 1); window.push_back('0'); if (used.find(window) == used.end()) squares[i] = 0; else { squares[i] = 1; window[9] = '1'; } used.insert(window); } return squares; } int find_location(int n, vector<int> c) { // squares = paint(n); if (c[9] == -1) { int num = -1; while(num < 10 && c[num+1] != -1) num++; return n - (num+1); } bool found; int pos = 0; for (int i = 0; i <= n-10; i++) { found = true; for (int j = 0; j < 10; j++) { if (squares[i+j] != c[j]) { found = false; break; } } if (found) { pos = i; break; } } return pos; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...