#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]}) >= 200){
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) / 16){
ans = 1;
}
else{
ans = 4;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
7288 KB |
Output is correct |
2 |
Correct |
46 ms |
4844 KB |
Output is correct |
3 |
Incorrect |
85 ms |
6164 KB |
Output isn't correct |
4 |
Correct |
59 ms |
3868 KB |
Output is correct |
5 |
Incorrect |
54 ms |
4396 KB |
Output isn't correct |
6 |
Correct |
47 ms |
3996 KB |
Output is correct |
7 |
Correct |
39 ms |
4276 KB |
Output is correct |
8 |
Incorrect |
71 ms |
3676 KB |
Output isn't correct |
9 |
Correct |
65 ms |
4260 KB |
Output is correct |
10 |
Correct |
83 ms |
7244 KB |
Output is correct |
11 |
Correct |
84 ms |
3716 KB |
Output is correct |
12 |
Correct |
46 ms |
4708 KB |
Output is correct |
13 |
Correct |
53 ms |
3988 KB |
Output is correct |
14 |
Incorrect |
73 ms |
5660 KB |
Output isn't correct |
15 |
Correct |
53 ms |
4440 KB |
Output is correct |
16 |
Correct |
89 ms |
7880 KB |
Output is correct |
17 |
Incorrect |
73 ms |
6380 KB |
Output isn't correct |
18 |
Correct |
68 ms |
4820 KB |
Output is correct |
19 |
Correct |
79 ms |
7776 KB |
Output is correct |
20 |
Correct |
66 ms |
6720 KB |
Output is correct |
21 |
Incorrect |
65 ms |
5136 KB |
Output isn't correct |
22 |
Correct |
49 ms |
4264 KB |
Output is correct |
23 |
Correct |
46 ms |
4532 KB |
Output is correct |
24 |
Correct |
44 ms |
4532 KB |
Output is correct |
25 |
Correct |
32 ms |
4356 KB |
Output is correct |
26 |
Incorrect |
81 ms |
6732 KB |
Output isn't correct |
27 |
Correct |
49 ms |
3324 KB |
Output is correct |
28 |
Correct |
43 ms |
2764 KB |
Output is correct |
29 |
Correct |
44 ms |
4016 KB |
Output is correct |
30 |
Correct |
79 ms |
4144 KB |
Output is correct |
31 |
Incorrect |
65 ms |
5516 KB |
Output isn't correct |
32 |
Incorrect |
103 ms |
6796 KB |
Output isn't correct |
33 |
Correct |
48 ms |
3324 KB |
Output is correct |
34 |
Correct |
86 ms |
7148 KB |
Output is correct |
35 |
Correct |
70 ms |
4556 KB |
Output is correct |
36 |
Correct |
73 ms |
5680 KB |
Output is correct |
37 |
Correct |
100 ms |
7704 KB |
Output is correct |
38 |
Incorrect |
57 ms |
4132 KB |
Output isn't correct |
39 |
Correct |
81 ms |
6324 KB |
Output is correct |
40 |
Correct |
50 ms |
4096 KB |
Output is correct |
41 |
Incorrect |
78 ms |
4776 KB |
Output isn't correct |
42 |
Correct |
82 ms |
7708 KB |
Output is correct |
43 |
Correct |
82 ms |
4736 KB |
Output is correct |
44 |
Incorrect |
88 ms |
7644 KB |
Output isn't correct |
45 |
Correct |
57 ms |
5000 KB |
Output is correct |
46 |
Incorrect |
58 ms |
3876 KB |
Output isn't correct |
47 |
Correct |
68 ms |
4508 KB |
Output is correct |
48 |
Incorrect |
59 ms |
3652 KB |
Output isn't correct |
49 |
Incorrect |
83 ms |
7844 KB |
Output isn't correct |
50 |
Incorrect |
80 ms |
7148 KB |
Output isn't correct |
51 |
Incorrect |
76 ms |
5696 KB |
Output isn't correct |
52 |
Incorrect |
67 ms |
4492 KB |
Output isn't correct |
53 |
Incorrect |
69 ms |
4872 KB |
Output isn't correct |
54 |
Incorrect |
77 ms |
7504 KB |
Output isn't correct |
55 |
Incorrect |
61 ms |
5136 KB |
Output isn't correct |
56 |
Incorrect |
55 ms |
4812 KB |
Output isn't correct |
57 |
Incorrect |
64 ms |
4780 KB |
Output isn't correct |
58 |
Correct |
98 ms |
9012 KB |
Output is correct |
59 |
Correct |
63 ms |
5284 KB |
Output is correct |
60 |
Correct |
49 ms |
4596 KB |
Output is correct |
61 |
Correct |
73 ms |
6368 KB |
Output is correct |
62 |
Incorrect |
50 ms |
3788 KB |
Output isn't correct |
63 |
Incorrect |
100 ms |
5136 KB |
Output isn't correct |
64 |
Correct |
60 ms |
6124 KB |
Output is correct |
65 |
Correct |
67 ms |
5348 KB |
Output is correct |
66 |
Correct |
61 ms |
5100 KB |
Output is correct |
67 |
Correct |
68 ms |
4444 KB |
Output is correct |
68 |
Correct |
15 ms |
3284 KB |
Output is correct |
69 |
Correct |
76 ms |
6592 KB |
Output is correct |
70 |
Correct |
76 ms |
6404 KB |
Output is correct |
71 |
Correct |
39 ms |
3840 KB |
Output is correct |
72 |
Correct |
49 ms |
3888 KB |
Output is correct |
73 |
Incorrect |
67 ms |
5252 KB |
Output isn't correct |
74 |
Incorrect |
44 ms |
3660 KB |
Output isn't correct |
75 |
Incorrect |
42 ms |
3656 KB |
Output isn't correct |
76 |
Correct |
44 ms |
4704 KB |
Output is correct |
77 |
Correct |
40 ms |
4384 KB |
Output is correct |
78 |
Incorrect |
63 ms |
5136 KB |
Output isn't correct |
79 |
Correct |
37 ms |
2636 KB |
Output is correct |
80 |
Incorrect |
78 ms |
7224 KB |
Output isn't correct |
81 |
Correct |
63 ms |
5112 KB |
Output is correct |
82 |
Correct |
36 ms |
3788 KB |
Output is correct |
83 |
Incorrect |
24 ms |
1896 KB |
Output isn't correct |
84 |
Correct |
67 ms |
3852 KB |
Output is correct |
85 |
Correct |
73 ms |
3944 KB |
Output is correct |
86 |
Correct |
59 ms |
3536 KB |
Output is correct |
87 |
Correct |
55 ms |
4000 KB |
Output is correct |
88 |
Correct |
67 ms |
6468 KB |
Output is correct |
89 |
Correct |
89 ms |
8020 KB |
Output is correct |
90 |
Incorrect |
84 ms |
6280 KB |
Output isn't correct |
91 |
Correct |
69 ms |
4632 KB |
Output is correct |
92 |
Incorrect |
82 ms |
6572 KB |
Output isn't correct |
93 |
Correct |
50 ms |
3904 KB |
Output is correct |
94 |
Correct |
60 ms |
6608 KB |
Output is correct |
95 |
Incorrect |
78 ms |
6296 KB |
Output isn't correct |
96 |
Correct |
49 ms |
3676 KB |
Output is correct |
97 |
Correct |
76 ms |
6428 KB |
Output is correct |
98 |
Incorrect |
78 ms |
6664 KB |
Output isn't correct |
99 |
Correct |
75 ms |
6700 KB |
Output is correct |
100 |
Correct |
53 ms |
3240 KB |
Output is correct |
101 |
Correct |
61 ms |
3816 KB |
Output is correct |
102 |
Correct |
79 ms |
3916 KB |
Output is correct |