답안 #395834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395834 2021-04-29T03:21:43 Z khangal 벽 칠하기 (APIO20_paint) C++14
0 / 100
1500 ms 29260 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef double db;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define pb push_back
#define po pop_back
#define ff first
#define ss second
#define MIN -1e18
#define MAX 1e18
#define lw lower_bound
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,mid,mn,T,sum,c[1234567],h1,h2,x,y,z,l,r,cnt,cnt1,ans;
vector<ll> vec[1234567];
bool ok[1234567],ok1;	
int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	for(int i=0;i<M;i++){
		for(auto u:B[i]) vec[u].pb(i);	
	}
	vector<vector<ll> > mp(M);
	for(int i=0;i<N;i++){
		for(auto u:vec[C[i]]){
			mp[((u-i)%M+M)%M].pb(i);
		}
	}
	vl v(N);
	for(auto u:mp){
		ll last = N+1;
		ll len =0;
		for(int i=u.size()-1;i>=0;i--){
			if(u[i]+1!=last)len=0;
			len++;
			v[u[i]]=max(v[u[i]],len);
			last=u[i];
		}
	}
	vl ok;
	for(int i=0;i<N;i++)if(v[i]>=M)ok.pb(i);
	ll Rpoint=0;
	ll id=0;
	while(Rpoint<N){
		while(id<ok.size()&&ok[id]<=Rpoint){
			id++;
		}
		if(id==0)return -1;
		ll Lpoint = ok[id-1];
		if(Lpoint + M <= Rpoint)return -1;
		ans++;
	}
	return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:49:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   while(id<ok.size()&&ok[id]<=Rpoint){
      |         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 29260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 29260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 29260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 29260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 29260 KB Time limit exceeded
2 Halted 0 ms 0 KB -