This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <map>
using namespace std;
vector<int> paint(int n) {
vector<int> squares = vector<int>(n+1);
map<string, int> used;
squares[n] = 10;
string window = "1111111111";
used.clear();
for (int i = 0; i < 10; i++) {
if (i == n)
break;
squares[i] = 1;
}
used[window] = 0;
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[window] = i - 9;
}
return squares;
}
int find_location(int n, vector<int> c) {
for (int i = 0; i < (int) c.size(); i++) {
if (c[i] == -1)
return n - i;
}
vector<int> squares = vector<int>(n+1);
map<string, int> used;
squares[n] = 10;
string window = "1111111111";
string s = "";
for (int i = 0; i < (int) c.size(); i++)
s.push_back('0' + c[i]);
for (int i = 0; i < 10; i++)
squares[i] = 1;
used[window] = 0;
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[window] = i - 9;
}
return used[s];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |