| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 752675 | benjaminkleyn | Painting Walls (APIO20_paint) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "paint.h"
using namespace std;
struct section
{
// used to store a segment of the wall which i know can be painted nicely.
int x, y, cnt;
// we can do this for 0 <= l < cnt, instead of just M.
};
bool operator<(const section &X, const section &Y)
{
return X.y + X.cnt < Y.y + Y.cnt;
}
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B)
{
vector<set<int>> b(M);
for (int i = 0; i < M; i++)
b[i] = set<int>(B[i].begin(), B[i].end());
vector<section> sections1;
vector<section> sections2;
for (int offset = 0; offset < M; offset++)
{
int cnt = 0;
for (int i = 0; i < N; i++)
{
if (b[(i + offset) % M].find(C[i]) == b[(i + offset) % M].end())
{
if (cnt >= M)
{
sections1.push_back({(i - cnt + offset) % M, i - cnt, cnt});
sections2.push_back({(i - cnt + offset) % M, i - cnt, cnt});
}
cnt = 0;
}
else
cnt++;
}
if (cnt >= M)
{
sections1.push_back({(N - cnt + offset) % M, N - cnt, cnt});
sections2.push_back({(N - cnt + offset) % M, N - cnt, cnt});
}
}
sort(sections2.begin(), sections2.end());
sort(sections1.begin(), sections1.end(),
[] (const section &X, const section &Y)
{
return X.y < Y.y;
}
);
vector<bool> done(N, false);
int ans = 0;
set<section> sections;
int l = 0, r = 0;
for (int i = 0; i < N; i++)
{
while (r < sections1.size() && sections1[r].y == i)
sections.insert(sections1[r++]);
if (!done[i])
{
auto [x, y, cnt] = *sections.rbegin();
ans++;
for (int j = i; j < N && j < y + cnt && j < i + M; j++)
done[j] = true;
}
while (l <= r && sections2[l].y + sections2[l].cnt - 1 == i)
sections.erase(sections2[l++]);
}
return ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
