답안 #743055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743055 2023-05-17T07:40:20 Z tolbi 벽 칠하기 (APIO20_paint) C++17
15 / 100
1500 ms 524288 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X, typename Y> pair<X,Y> operator+(pair<X,Y> a, pair<X,Y> b) {pair<X,Y> c; c.first=a.first+b.first,c.second=a.second+b.second;return c;}
template<typename X, typename Y> pair<X,Y> operator-(pair<X,Y> a, pair<X,Y> b) {pair<X,Y> c; c.first=a.first-b.first,c.second=a.second-b.second;return c;}
template<typename X, typename Y> void operator+=(pair<X,Y> &a, pair<X,Y> b){a.first+=b.first,a.second+=b.second;}
template<typename X, typename Y> void operator-=(pair<X,Y> &a, pair<X,Y> b){a.first-=b.first,a.second-=b.second;}
template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;}
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "paint.h"
 
int32_t minimumInstructions(int32_t N, int32_t M, int32_t K, vector<int32_t> C, vector<int32_t> A, vector<vector<int32_t>> B) {
	vector<map<int,int>> mp(N);
	vector<int> mava(N,0);
	vector<set<int>> st(K);
	for (int i = 0; i < N; i++){
		st[C[i]].insert(i);
	}
	for (int i = 0; i < M; i++){
		for (int j = 0; j < B[i].size(); j++){
			int col = B[i][j];
			auto it = st[col].begin();
			while (it!=st[col].end()){
				int pos = *it;
				for (int k = 0; k < M && pos-k>=0; k++){
					mp[pos-k][(i-k+M)%M]++;
					mava[pos-k]=max(mava[pos-k],mp[pos-k][(i-k+M)%M]);
				}
				it++;
			}
		}
	}
	int32_t ans = 1, r = M-1, mavava = M-1;
	if (mava[0]<M) return -1;
	for (int i = 1; i < N; i++){
		if (mava[i]>=M) mavava=i+M-1;
		if (i>r){
			if (mavava==r) return -1;
			r=mavava;
			ans++;
		}
	}
	return ans;
}
 
#ifdef tolbi
int32_t main() {
	int32_t N, M, K;
	assert(3 == scanf("%d %d %d", &N, &M, &K));
 
	vector<int32_t> C(N);
	for (int32_t i = 0; i < N; ++i) {
		assert(1 == scanf("%d", &C[i]));
	}
 
	vector<int32_t> A(M);
	vector<vector<int32_t>> B(M);
	for (int32_t i = 0; i < M; ++i) {
		assert(1 == scanf("%d", &A[i]));
		B[i].resize(A[i]);
		for (int32_t j = 0; j < A[i]; ++j) {
			assert(1 == scanf("%d", &B[i][j]));
		}
	}
 
	int32_t minimum_instructions = minimumInstructions(N, M, K, C, A, B);
	printf("%d\n", minimum_instructions);
 
	return 0;
}
#endif

Compilation message

paint.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
paint.cpp: In function 'int32_t minimumInstructions(int32_t, int32_t, int32_t, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:50:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int j = 0; j < B[i].size(); j++){
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 228 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 4 ms 5072 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5088 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5044 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 4 ms 5176 KB Output is correct
21 Correct 4 ms 5044 KB Output is correct
22 Correct 37 ms 9548 KB Output is correct
23 Correct 31 ms 9684 KB Output is correct
24 Correct 28 ms 9584 KB Output is correct
25 Correct 10 ms 3784 KB Output is correct
26 Correct 9 ms 3748 KB Output is correct
27 Correct 13 ms 4308 KB Output is correct
28 Correct 13 ms 5076 KB Output is correct
29 Correct 15 ms 5944 KB Output is correct
30 Correct 21 ms 6740 KB Output is correct
31 Correct 238 ms 8968 KB Output is correct
32 Correct 248 ms 8928 KB Output is correct
33 Correct 275 ms 9028 KB Output is correct
34 Correct 221 ms 9064 KB Output is correct
35 Correct 230 ms 9096 KB Output is correct
36 Correct 238 ms 8968 KB Output is correct
37 Runtime error 1020 ms 524288 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 228 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 4 ms 5072 KB Output is correct
14 Correct 5 ms 5076 KB Output is correct
15 Correct 3 ms 5088 KB Output is correct
16 Correct 3 ms 5076 KB Output is correct
17 Correct 3 ms 5076 KB Output is correct
18 Correct 3 ms 5044 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 4 ms 5176 KB Output is correct
21 Correct 4 ms 5044 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 304 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 7 ms 852 KB Output is correct
29 Correct 7 ms 852 KB Output is correct
30 Correct 6 ms 852 KB Output is correct
31 Correct 2 ms 560 KB Output is correct
32 Correct 11 ms 1412 KB Output is correct
33 Correct 3 ms 4308 KB Output is correct
34 Correct 3 ms 3284 KB Output is correct
35 Correct 3 ms 2900 KB Output is correct
36 Correct 4 ms 4932 KB Output is correct
37 Correct 4 ms 4020 KB Output is correct
38 Correct 3 ms 4400 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 4 ms 3888 KB Output is correct
41 Correct 8 ms 2004 KB Output is correct
42 Correct 4 ms 4820 KB Output is correct
43 Correct 3 ms 4692 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 15 ms 1236 KB Output is correct
46 Correct 24 ms 1620 KB Output is correct
47 Correct 24 ms 1936 KB Output is correct
48 Correct 21 ms 2132 KB Output is correct
49 Correct 41 ms 2260 KB Output is correct
50 Correct 3 ms 5076 KB Output is correct
51 Correct 4 ms 5076 KB Output is correct
52 Correct 4 ms 5076 KB Output is correct
53 Correct 4 ms 5048 KB Output is correct
54 Correct 4 ms 5040 KB Output is correct
55 Correct 4 ms 5076 KB Output is correct
56 Correct 5 ms 5076 KB Output is correct
57 Correct 11 ms 3668 KB Output is correct
58 Correct 3 ms 5044 KB Output is correct
59 Correct 33 ms 3540 KB Output is correct
60 Correct 3 ms 5076 KB Output is correct
61 Correct 19 ms 3668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 228 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 432 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 4 ms 5072 KB Output is correct
16 Correct 5 ms 5076 KB Output is correct
17 Correct 3 ms 5088 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5044 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 4 ms 5176 KB Output is correct
23 Correct 4 ms 5044 KB Output is correct
24 Correct 37 ms 9548 KB Output is correct
25 Correct 31 ms 9684 KB Output is correct
26 Correct 28 ms 9584 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 7 ms 852 KB Output is correct
32 Correct 7 ms 852 KB Output is correct
33 Correct 6 ms 852 KB Output is correct
34 Correct 2 ms 560 KB Output is correct
35 Correct 11 ms 1412 KB Output is correct
36 Correct 3 ms 4308 KB Output is correct
37 Correct 3 ms 3284 KB Output is correct
38 Correct 3 ms 2900 KB Output is correct
39 Correct 4 ms 4932 KB Output is correct
40 Correct 4 ms 4020 KB Output is correct
41 Correct 3 ms 4400 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 4 ms 3888 KB Output is correct
44 Correct 8 ms 2004 KB Output is correct
45 Correct 4 ms 4820 KB Output is correct
46 Correct 3 ms 4692 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 15 ms 1236 KB Output is correct
49 Correct 24 ms 1620 KB Output is correct
50 Correct 24 ms 1936 KB Output is correct
51 Correct 21 ms 2132 KB Output is correct
52 Correct 41 ms 2260 KB Output is correct
53 Correct 3 ms 5076 KB Output is correct
54 Correct 4 ms 5076 KB Output is correct
55 Correct 4 ms 5076 KB Output is correct
56 Correct 4 ms 5048 KB Output is correct
57 Correct 4 ms 5040 KB Output is correct
58 Correct 4 ms 5076 KB Output is correct
59 Correct 5 ms 5076 KB Output is correct
60 Correct 11 ms 3668 KB Output is correct
61 Correct 3 ms 5044 KB Output is correct
62 Correct 33 ms 3540 KB Output is correct
63 Correct 3 ms 5076 KB Output is correct
64 Correct 19 ms 3668 KB Output is correct
65 Correct 329 ms 3280 KB Output is correct
66 Correct 38 ms 1532 KB Output is correct
67 Correct 462 ms 4148 KB Output is correct
68 Correct 149 ms 2556 KB Output is correct
69 Correct 359 ms 3776 KB Output is correct
70 Correct 89 ms 5560 KB Output is correct
71 Correct 54 ms 4868 KB Output is correct
72 Correct 31 ms 4424 KB Output is correct
73 Correct 7 ms 4052 KB Output is correct
74 Correct 63 ms 5312 KB Output is correct
75 Correct 35 ms 5868 KB Output is correct
76 Correct 24 ms 6476 KB Output is correct
77 Correct 18 ms 6092 KB Output is correct
78 Correct 39 ms 7316 KB Output is correct
79 Execution timed out 1525 ms 6744 KB Time limit exceeded
80 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 228 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 432 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 4 ms 5072 KB Output is correct
16 Correct 5 ms 5076 KB Output is correct
17 Correct 3 ms 5088 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5044 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 4 ms 5176 KB Output is correct
23 Correct 4 ms 5044 KB Output is correct
24 Correct 37 ms 9548 KB Output is correct
25 Correct 31 ms 9684 KB Output is correct
26 Correct 28 ms 9584 KB Output is correct
27 Correct 10 ms 3784 KB Output is correct
28 Correct 9 ms 3748 KB Output is correct
29 Correct 13 ms 4308 KB Output is correct
30 Correct 13 ms 5076 KB Output is correct
31 Correct 15 ms 5944 KB Output is correct
32 Correct 21 ms 6740 KB Output is correct
33 Correct 238 ms 8968 KB Output is correct
34 Correct 248 ms 8928 KB Output is correct
35 Correct 275 ms 9028 KB Output is correct
36 Correct 221 ms 9064 KB Output is correct
37 Correct 230 ms 9096 KB Output is correct
38 Correct 238 ms 8968 KB Output is correct
39 Runtime error 1020 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 228 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 280 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 432 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 4 ms 5072 KB Output is correct
16 Correct 5 ms 5076 KB Output is correct
17 Correct 3 ms 5088 KB Output is correct
18 Correct 3 ms 5076 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5044 KB Output is correct
21 Correct 3 ms 5076 KB Output is correct
22 Correct 4 ms 5176 KB Output is correct
23 Correct 4 ms 5044 KB Output is correct
24 Correct 37 ms 9548 KB Output is correct
25 Correct 31 ms 9684 KB Output is correct
26 Correct 28 ms 9584 KB Output is correct
27 Correct 10 ms 3784 KB Output is correct
28 Correct 9 ms 3748 KB Output is correct
29 Correct 13 ms 4308 KB Output is correct
30 Correct 13 ms 5076 KB Output is correct
31 Correct 15 ms 5944 KB Output is correct
32 Correct 21 ms 6740 KB Output is correct
33 Correct 238 ms 8968 KB Output is correct
34 Correct 248 ms 8928 KB Output is correct
35 Correct 275 ms 9028 KB Output is correct
36 Correct 221 ms 9064 KB Output is correct
37 Correct 230 ms 9096 KB Output is correct
38 Correct 238 ms 8968 KB Output is correct
39 Runtime error 1020 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -