Submission #842459

# Submission time Handle Problem Language Result Execution time Memory
842459 2023-09-02T22:43:29 Z pera Colouring a rectangle (eJOI19_colouring) C++17
30 / 100
72 ms 18232 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int N = 2e5 + 1;

main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n , m;cin >> n >> m;
	vector<int> d1(n + m - 1) , d2(n + m - 1) , sz(n + m - 1); 
	int ans = 1e18 , s = 0;
	for(int i = 0;i < n + m - 1;i ++){
		cin >> d1[i];
		if(i < min(n , m)) sz[i] = i + 1;
		if(min(n , m) <= i && i < max(n , m)) sz[i] = sz[i - 1];
		if(i >= max(n , m)) sz[i] = sz[i - 1] - 1;
	}
	for(int i = 0;i < n + m - 1;i ++){
		cin >> d2[i];
		if(n == 1) s += min(d2[i] , d1[m - i - 1]);
	}
	if(n == 1){
		cout << s << endl;
		return 0;
	}
	for(int mk = 0;mk < (1 << (n + m - 1));mk ++){
		int s = 0;
		vector<int> f(n + m - 1);
		for(int i = 0;i < n + m - 1;i ++){
			if((1 << i) & mk) s += d1[i];
			else{
				int st;
				if(i < m){
					st = m - i - 1;
				}else{
					st = i - m + 1;
				}
				int x = sz[i];
				while(x --){
					if(!f[st]) s += d2[st];
					f[st] = 1;
					st += 2;
				}
			}
		}
		ans = min(ans , s);
	} 
	cout << ans << endl;
}

Compilation message

colouring.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 72 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 71 ms 432 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 70 ms 348 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 72 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 71 ms 432 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 70 ms 348 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Incorrect 1 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 72 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 71 ms 432 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 70 ms 348 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Incorrect 1 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 6744 KB Output is correct
2 Correct 31 ms 8976 KB Output is correct
3 Correct 31 ms 8796 KB Output is correct
4 Correct 35 ms 9044 KB Output is correct
5 Correct 33 ms 9240 KB Output is correct
6 Correct 31 ms 8452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 18232 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 72 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 71 ms 432 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 70 ms 348 KB Output is correct
19 Correct 34 ms 348 KB Output is correct
20 Incorrect 1 ms 348 KB Output isn't correct
21 Halted 0 ms 0 KB -