이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <vector>
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define ll long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define x first
#define y second
using namespace std;
int minimumInstructions(int N, int M, int K, vector<int> C,
vector<int> A, vector<vector<int>> B) {
vector<vector<int>> mp(K, vector<int>());
vector<set<int>> col(M, set<int>());
rep(i, 0, M - 1) for(auto j : B[i]) {
mp[j].push_back(i);
col[i].insert(j);
}
set<int> t, s;
rep(i, 0, N - 1) t.insert(i);
auto pos = [&](int x, int s, int t) {
return ((x + (t - s)) % M + M) % M;
};
for(int i = M - 1; i < N; i += M) {
for(auto j : mp[C[i]]) {
int l = i, r = i;
while(l - 1 >= 0 && col[pos(j, i, l - 1)].count(C[l - 1])) l--;
while(r + 1 < N && col[pos(j, i, r + 1)].count(C[r + 1])) r++;
auto it = t.lower_bound(l);
while(it != t.end()) {
if(*it + M - 1 > r) break;
auto tp = it;
it = next(it);
t.erase(tp);
}
}
}
rep(i, 0, N - 1) if(!t.count(i)) s.insert(i);
int cnt = 0, cur = 0;
while(cur < N) {
auto it = s.upper_bound(cur);
if(it == s.begin()) return -1;
it = prev(it);
if(*it + M <= cur) return -1;
cur = *it + M;
cnt ++;
}
return cnt;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp:8: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
8 | #pragma loop-opt(on)
|
paint.cpp:23:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
23 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
paint.cpp:23:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
23 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
# | 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... |