#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) / 4;
ll polla = 50000;
ll ans;
set<ll>ex;
ll prasina = 0;
ll aspro = 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]}) >= 200){
aspro++;
}
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 >= posa / 2){
ans = 1;
}
else{
ans = 4;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
4816 KB |
Output is correct |
2 |
Correct |
54 ms |
4504 KB |
Output is correct |
3 |
Correct |
58 ms |
6080 KB |
Output is correct |
4 |
Correct |
49 ms |
4940 KB |
Output is correct |
5 |
Correct |
53 ms |
3664 KB |
Output is correct |
6 |
Correct |
79 ms |
6724 KB |
Output is correct |
7 |
Correct |
65 ms |
6428 KB |
Output is correct |
8 |
Incorrect |
86 ms |
5216 KB |
Output isn't correct |
9 |
Correct |
77 ms |
5328 KB |
Output is correct |
10 |
Incorrect |
59 ms |
4504 KB |
Output isn't correct |
11 |
Correct |
86 ms |
6220 KB |
Output is correct |
12 |
Incorrect |
80 ms |
7060 KB |
Output isn't correct |
13 |
Correct |
82 ms |
6552 KB |
Output is correct |
14 |
Correct |
43 ms |
2720 KB |
Output is correct |
15 |
Incorrect |
56 ms |
4168 KB |
Output isn't correct |
16 |
Incorrect |
51 ms |
3820 KB |
Output isn't correct |
17 |
Incorrect |
19 ms |
1904 KB |
Output isn't correct |
18 |
Incorrect |
68 ms |
3624 KB |
Output isn't correct |
19 |
Correct |
41 ms |
3904 KB |
Output is correct |
20 |
Correct |
61 ms |
4428 KB |
Output is correct |
21 |
Incorrect |
58 ms |
3884 KB |
Output isn't correct |
22 |
Incorrect |
62 ms |
4748 KB |
Output isn't correct |
23 |
Incorrect |
63 ms |
3572 KB |
Output isn't correct |
24 |
Correct |
52 ms |
3324 KB |
Output is correct |
25 |
Correct |
60 ms |
3828 KB |
Output is correct |
26 |
Correct |
118 ms |
9148 KB |
Output is correct |
27 |
Correct |
63 ms |
4904 KB |
Output is correct |
28 |
Correct |
74 ms |
3960 KB |
Output is correct |
29 |
Correct |
71 ms |
4188 KB |
Output is correct |
30 |
Correct |
69 ms |
3824 KB |
Output is correct |
31 |
Incorrect |
99 ms |
6848 KB |
Output isn't correct |
32 |
Correct |
86 ms |
7328 KB |
Output is correct |
33 |
Correct |
63 ms |
3876 KB |
Output is correct |
34 |
Correct |
61 ms |
6608 KB |
Output is correct |
35 |
Incorrect |
62 ms |
5192 KB |
Output isn't correct |
36 |
Correct |
78 ms |
7124 KB |
Output is correct |
37 |
Correct |
89 ms |
8048 KB |
Output is correct |
38 |
Correct |
55 ms |
3972 KB |
Output is correct |
39 |
Correct |
54 ms |
3952 KB |
Output is correct |
40 |
Incorrect |
80 ms |
6800 KB |
Output isn't correct |
41 |
Correct |
72 ms |
4524 KB |
Output is correct |
42 |
Correct |
86 ms |
7192 KB |
Output is correct |
43 |
Correct |
38 ms |
3868 KB |
Output is correct |
44 |
Incorrect |
117 ms |
6276 KB |
Output isn't correct |
45 |
Incorrect |
58 ms |
3296 KB |
Output isn't correct |
46 |
Correct |
92 ms |
4776 KB |
Output is correct |
47 |
Correct |
48 ms |
4504 KB |
Output is correct |
48 |
Correct |
79 ms |
6636 KB |
Output is correct |
49 |
Correct |
85 ms |
7828 KB |
Output is correct |
50 |
Incorrect |
70 ms |
5660 KB |
Output isn't correct |
51 |
Correct |
18 ms |
3284 KB |
Output is correct |
52 |
Incorrect |
52 ms |
3748 KB |
Output isn't correct |
53 |
Incorrect |
87 ms |
4848 KB |
Output isn't correct |
54 |
Incorrect |
82 ms |
5732 KB |
Output isn't correct |
55 |
Correct |
85 ms |
7680 KB |
Output is correct |
56 |
Correct |
43 ms |
4684 KB |
Output is correct |
57 |
Correct |
49 ms |
2764 KB |
Output is correct |
58 |
Incorrect |
100 ms |
6188 KB |
Output isn't correct |
59 |
Correct |
82 ms |
6708 KB |
Output is correct |
60 |
Incorrect |
81 ms |
7132 KB |
Output isn't correct |
61 |
Incorrect |
83 ms |
6424 KB |
Output isn't correct |
62 |
Incorrect |
46 ms |
4008 KB |
Output isn't correct |
63 |
Correct |
87 ms |
7580 KB |
Output is correct |
64 |
Correct |
79 ms |
6420 KB |
Output is correct |
65 |
Correct |
94 ms |
7884 KB |
Output is correct |
66 |
Correct |
75 ms |
5208 KB |
Output is correct |
67 |
Correct |
59 ms |
3988 KB |
Output is correct |
68 |
Correct |
64 ms |
5348 KB |
Output is correct |
69 |
Incorrect |
39 ms |
3644 KB |
Output isn't correct |
70 |
Correct |
61 ms |
6604 KB |
Output is correct |
71 |
Correct |
59 ms |
4044 KB |
Output is correct |
72 |
Incorrect |
63 ms |
4748 KB |
Output isn't correct |
73 |
Incorrect |
57 ms |
3536 KB |
Output isn't correct |
74 |
Correct |
82 ms |
7808 KB |
Output is correct |
75 |
Correct |
49 ms |
4412 KB |
Output is correct |
76 |
Correct |
49 ms |
4636 KB |
Output is correct |
77 |
Correct |
67 ms |
4556 KB |
Output is correct |
78 |
Correct |
77 ms |
6460 KB |
Output is correct |
79 |
Correct |
63 ms |
5004 KB |
Output is correct |
80 |
Correct |
58 ms |
4440 KB |
Output is correct |
81 |
Correct |
74 ms |
5748 KB |
Output is correct |
82 |
Incorrect |
78 ms |
5244 KB |
Output isn't correct |
83 |
Incorrect |
88 ms |
5524 KB |
Output isn't correct |
84 |
Incorrect |
61 ms |
4452 KB |
Output isn't correct |
85 |
Correct |
73 ms |
4416 KB |
Output is correct |
86 |
Correct |
48 ms |
3972 KB |
Output is correct |
87 |
Correct |
54 ms |
3448 KB |
Output is correct |
88 |
Correct |
79 ms |
6480 KB |
Output is correct |
89 |
Correct |
37 ms |
4344 KB |
Output is correct |
90 |
Correct |
87 ms |
6628 KB |
Output is correct |
91 |
Incorrect |
84 ms |
7520 KB |
Output isn't correct |
92 |
Incorrect |
83 ms |
4880 KB |
Output isn't correct |
93 |
Correct |
64 ms |
3792 KB |
Output is correct |
94 |
Incorrect |
79 ms |
5168 KB |
Output isn't correct |
95 |
Correct |
86 ms |
7684 KB |
Output is correct |
96 |
Incorrect |
72 ms |
5084 KB |
Output isn't correct |
97 |
Incorrect |
64 ms |
4216 KB |
Output isn't correct |
98 |
Correct |
52 ms |
4260 KB |
Output is correct |
99 |
Correct |
65 ms |
3792 KB |
Output is correct |
100 |
Correct |
49 ms |
4108 KB |
Output is correct |
101 |
Correct |
52 ms |
4712 KB |
Output is correct |
102 |
Correct |
55 ms |
4296 KB |
Output is correct |