#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<ll> distr;
ll rnd(ll a, ll b){return distr(rng)%(b-a+1)+a;}
#include "artclass.h"
/*
#ifndef __ARTCLASS_H__
#define __ARTCLASS_H__
#ifdef __cplusplus
extern "C" {
#endif
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]);
#ifdef __cplusplus
}
#endif
#endif
#include <stdio.h>
static int DIM[2];
static int R[500][500];
static int G[500][500];
static int B[500][500];
int main() {
FILE *in = fopen("artclass.txt", "r");
if(in == NULL) {
puts("Failed to open input file (artclass.txt).");
return 0;
}
if(fscanf(in, "%d%d", DIM, DIM+1) != 2) {
printf("Line 1: H, W must be integers\n");
return 0;
}
if(DIM[0] < 100 || 500 < DIM[0]) {
printf("Line 1: 100 <= H <= 500\n");
return 0;
}
if(DIM[1] < 100 || 500 < DIM[1]) {
printf("Line 1: 100 <= W <= 500\n");
return 0;
}
for(int i = 0; i< DIM[0]; i++) {
for(int j = 0; j < DIM[1]; j++) {
if(fscanf(in, "%d%d%d", &R[i][j], &G[i][j], &B[i][j]) != 3) {
printf("Line %d: R[i][j], G[i][j], B[i][j] must be integers", i*DIM[1]+j+2, i, j);
return 0;
}
if(R[i][j] < 0 || 255 < R[i][j]) {
printf("Line %d: 0 <= R[%d][%d] <= 255", i*DIM[1]+j+2, i, j);
return 0;
}
if(G[i][j] < 0 || 255 < G[i][j]) {
printf("Line %d: 0 <= G[%d][%d] <= 255", i*DIM[1]+j+2, i, j);
return 0;
}
if(B[i][j] < 0 || 255 < B[i][j]) {
printf("Line %d: 0 <= B[%d][%d] <= 255", i*DIM[1]+j+2, i, j);
return 0;
}
}
}
printf("%d\n", style(DIM[0], DIM[1], R, G, B));
return 0;
}
*/
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
ll n = H,m = W;
ll posa = (n * m) / 2;
ll polla = 50000;
ll ans;
set<ll>ex;
ll prasina = 0;
ll aspro = 0;
ll mavro = 0;
ll allages = 0;
f(i,0,n){
f(j,0,m){
ex.insert(R[i][j] + 256 * G[i][j] + 256 * 256 * B[i][j]);
if(G[i][j] >= max({70,R[i][j],B[i][j]})){
prasina++;
}
if(min({G[i][j],R[i][j],B[i][j]}) >= 170){
aspro++;
}
if(max({G[i][j],R[i][j],B[i][j]}) <= 70 && max({G[i][j],R[i][j],B[i][j]}) - min({G[i][j],R[i][j],B[i][j]}) <= 20){
mavro++;
}
if(j != 0){
allages += (abs(G[i][j] - G[i][j-1]) + abs(B[i][j] - B[i][j-1]) + abs(R[i][j] - R[i][j-1])) >= 100;
}
}
}
if(polla <= (ll)ex.size()){
if(prasina >= posa && allages <= posa){
ans = 2;
}
else{
ans = 3;
}
}
else{
if(aspro >= (n * m) / 8 && mavro >= (n * m) / 32){
ans = 1;
}
else{
ans = 4;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
4684 KB |
Output is correct |
2 |
Incorrect |
55 ms |
4832 KB |
Output isn't correct |
3 |
Correct |
105 ms |
7712 KB |
Output is correct |
4 |
Correct |
46 ms |
3880 KB |
Output is correct |
5 |
Incorrect |
37 ms |
3624 KB |
Output isn't correct |
6 |
Correct |
77 ms |
6400 KB |
Output is correct |
7 |
Correct |
74 ms |
6424 KB |
Output is correct |
8 |
Correct |
41 ms |
4300 KB |
Output is correct |
9 |
Correct |
46 ms |
4264 KB |
Output is correct |
10 |
Correct |
55 ms |
4004 KB |
Output is correct |
11 |
Correct |
57 ms |
5088 KB |
Output is correct |
12 |
Correct |
87 ms |
8016 KB |
Output is correct |
13 |
Correct |
71 ms |
5748 KB |
Output is correct |
14 |
Correct |
85 ms |
7604 KB |
Output is correct |
15 |
Correct |
73 ms |
4484 KB |
Output is correct |
16 |
Correct |
64 ms |
5396 KB |
Output is correct |
17 |
Correct |
77 ms |
3860 KB |
Output is correct |
18 |
Incorrect |
101 ms |
5768 KB |
Output isn't correct |
19 |
Correct |
73 ms |
6272 KB |
Output is correct |
20 |
Correct |
54 ms |
4436 KB |
Output is correct |
21 |
Correct |
60 ms |
3860 KB |
Output is correct |
22 |
Incorrect |
95 ms |
6288 KB |
Output isn't correct |
23 |
Incorrect |
53 ms |
3536 KB |
Output isn't correct |
24 |
Incorrect |
54 ms |
4416 KB |
Output isn't correct |
25 |
Correct |
45 ms |
4120 KB |
Output is correct |
26 |
Correct |
43 ms |
3980 KB |
Output is correct |
27 |
Correct |
49 ms |
3368 KB |
Output is correct |
28 |
Incorrect |
92 ms |
7244 KB |
Output isn't correct |
29 |
Incorrect |
81 ms |
6772 KB |
Output isn't correct |
30 |
Correct |
50 ms |
3860 KB |
Output is correct |
31 |
Correct |
62 ms |
3644 KB |
Output is correct |
32 |
Correct |
54 ms |
4112 KB |
Output is correct |
33 |
Correct |
80 ms |
7268 KB |
Output is correct |
34 |
Incorrect |
71 ms |
5196 KB |
Output isn't correct |
35 |
Correct |
96 ms |
9116 KB |
Output is correct |
36 |
Incorrect |
86 ms |
5236 KB |
Output isn't correct |
37 |
Correct |
56 ms |
3424 KB |
Output is correct |
38 |
Incorrect |
76 ms |
5224 KB |
Output isn't correct |
39 |
Incorrect |
73 ms |
5248 KB |
Output isn't correct |
40 |
Incorrect |
75 ms |
7524 KB |
Output isn't correct |
41 |
Correct |
49 ms |
3352 KB |
Output is correct |
42 |
Correct |
62 ms |
6440 KB |
Output is correct |
43 |
Incorrect |
78 ms |
6588 KB |
Output isn't correct |
44 |
Incorrect |
78 ms |
6912 KB |
Output isn't correct |
45 |
Correct |
42 ms |
4104 KB |
Output is correct |
46 |
Correct |
62 ms |
5336 KB |
Output is correct |
47 |
Incorrect |
18 ms |
1968 KB |
Output isn't correct |
48 |
Correct |
49 ms |
4596 KB |
Output is correct |
49 |
Correct |
33 ms |
4300 KB |
Output is correct |
50 |
Correct |
57 ms |
4760 KB |
Output is correct |
51 |
Correct |
79 ms |
6440 KB |
Output is correct |
52 |
Correct |
59 ms |
6708 KB |
Output is correct |
53 |
Correct |
63 ms |
4232 KB |
Output is correct |
54 |
Correct |
44 ms |
4804 KB |
Output is correct |
55 |
Incorrect |
44 ms |
3704 KB |
Output isn't correct |
56 |
Incorrect |
49 ms |
3852 KB |
Output isn't correct |
57 |
Incorrect |
67 ms |
5580 KB |
Output isn't correct |
58 |
Correct |
61 ms |
3812 KB |
Output is correct |
59 |
Correct |
56 ms |
4476 KB |
Output is correct |
60 |
Correct |
57 ms |
4960 KB |
Output is correct |
61 |
Correct |
84 ms |
8028 KB |
Output is correct |
62 |
Correct |
68 ms |
6752 KB |
Output is correct |
63 |
Incorrect |
76 ms |
6348 KB |
Output isn't correct |
64 |
Correct |
88 ms |
7272 KB |
Output is correct |
65 |
Correct |
37 ms |
4184 KB |
Output is correct |
66 |
Incorrect |
59 ms |
4828 KB |
Output isn't correct |
67 |
Correct |
83 ms |
7896 KB |
Output is correct |
68 |
Correct |
21 ms |
3300 KB |
Output is correct |
69 |
Correct |
47 ms |
3792 KB |
Output is correct |
70 |
Correct |
69 ms |
4588 KB |
Output is correct |
71 |
Correct |
62 ms |
4576 KB |
Output is correct |
72 |
Incorrect |
82 ms |
6136 KB |
Output isn't correct |
73 |
Correct |
46 ms |
3732 KB |
Output is correct |
74 |
Correct |
62 ms |
6560 KB |
Output is correct |
75 |
Incorrect |
61 ms |
5132 KB |
Output isn't correct |
76 |
Correct |
45 ms |
2844 KB |
Output is correct |
77 |
Correct |
56 ms |
4972 KB |
Output is correct |
78 |
Correct |
74 ms |
7068 KB |
Output is correct |
79 |
Correct |
45 ms |
4940 KB |
Output is correct |
80 |
Correct |
58 ms |
6112 KB |
Output is correct |
81 |
Correct |
84 ms |
3860 KB |
Output is correct |
82 |
Correct |
66 ms |
4864 KB |
Output is correct |
83 |
Incorrect |
78 ms |
7484 KB |
Output isn't correct |
84 |
Incorrect |
56 ms |
3852 KB |
Output isn't correct |
85 |
Correct |
51 ms |
3916 KB |
Output is correct |
86 |
Correct |
59 ms |
3852 KB |
Output is correct |
87 |
Incorrect |
65 ms |
5544 KB |
Output isn't correct |
88 |
Incorrect |
86 ms |
6400 KB |
Output isn't correct |
89 |
Correct |
55 ms |
4432 KB |
Output is correct |
90 |
Correct |
57 ms |
4028 KB |
Output is correct |
91 |
Incorrect |
63 ms |
4812 KB |
Output isn't correct |
92 |
Incorrect |
76 ms |
7144 KB |
Output isn't correct |
93 |
Incorrect |
81 ms |
7840 KB |
Output isn't correct |
94 |
Correct |
44 ms |
4508 KB |
Output is correct |
95 |
Incorrect |
70 ms |
4880 KB |
Output isn't correct |
96 |
Correct |
76 ms |
6688 KB |
Output is correct |
97 |
Correct |
58 ms |
4628 KB |
Output is correct |
98 |
Incorrect |
65 ms |
6580 KB |
Output isn't correct |
99 |
Correct |
50 ms |
3972 KB |
Output is correct |
100 |
Correct |
68 ms |
3640 KB |
Output is correct |
101 |
Incorrect |
61 ms |
4176 KB |
Output isn't correct |
102 |
Correct |
35 ms |
2744 KB |
Output is correct |