Submission #573763

# Submission time Handle Problem Language Result Execution time Memory
573763 2022-06-07T07:32:12 Z Theo830 Art Class (IOI13_artclass) C++17
54 / 100
116 ms 10736 KB
#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
#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) / 3;
    ll polla = 35000;
    ll ans;
    set<ll>ex;
    ll prasina = 0;
    ll aspro = 0;
    ll mavro = 0;
    ll allages = 0;
    ll boxes = 0;
    ll exo[n][m];
    f(i,0,n){
        f(j,0,m){
            exo[i][j] = 0;
            ex.insert(R[i][j] + 256 * G[i][j] + 256 * 256 * B[i][j]);
            if(G[i][j] >= max({20,R[i][j] - 20,B[i][j] - 20})){
                prasina++;
            }
            if(min({G[i][j],R[i][j],B[i][j]}) >= 170){
                exo[i][j] = 1;
                if(i > 0 && exo[i-1][j] == 1){

                }
                else if(j > 0 && exo[i][j-1] == 1){

                }
                else{
                    boxes++;
                }
                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(((aspro < (n * m) / 8) && (ll)ex.size() >= 65000) || (polla <= (ll)ex.size() && allages >= (n * m) / 8)){
         if(prasina >= posa && allages <= posa){
            ans = 2;
         }
         else{
            ans = 3;
         }
    }
    else{
        if(allages >= 1000 && aspro >= (n * m) / 8 && boxes >= 8){
            ans = 1;
        }
        else{
            ans = 4;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 7352 KB Output isn't correct
2 Incorrect 77 ms 7152 KB Output isn't correct
3 Correct 58 ms 4380 KB Output is correct
4 Correct 60 ms 6016 KB Output is correct
5 Correct 69 ms 6732 KB Output is correct
6 Correct 77 ms 7564 KB Output is correct
7 Correct 42 ms 5108 KB Output is correct
8 Incorrect 68 ms 6260 KB Output isn't correct
9 Correct 72 ms 5636 KB Output is correct
10 Incorrect 93 ms 8044 KB Output isn't correct
11 Incorrect 46 ms 5612 KB Output isn't correct
12 Correct 68 ms 6524 KB Output is correct
13 Correct 81 ms 8292 KB Output is correct
14 Correct 63 ms 5848 KB Output is correct
15 Incorrect 66 ms 7168 KB Output isn't correct
16 Correct 36 ms 3656 KB Output is correct
17 Incorrect 58 ms 5068 KB Output isn't correct
18 Incorrect 72 ms 6308 KB Output isn't correct
19 Correct 77 ms 8320 KB Output is correct
20 Incorrect 77 ms 8632 KB Output isn't correct
21 Correct 113 ms 9116 KB Output is correct
22 Correct 61 ms 5256 KB Output is correct
23 Incorrect 85 ms 8272 KB Output isn't correct
24 Correct 44 ms 4336 KB Output is correct
25 Correct 53 ms 5044 KB Output is correct
26 Correct 65 ms 7828 KB Output is correct
27 Correct 62 ms 6144 KB Output is correct
28 Correct 73 ms 7896 KB Output is correct
29 Correct 74 ms 7888 KB Output is correct
30 Correct 70 ms 7068 KB Output is correct
31 Incorrect 65 ms 6540 KB Output isn't correct
32 Correct 39 ms 4940 KB Output is correct
33 Correct 59 ms 7724 KB Output is correct
34 Incorrect 86 ms 6724 KB Output isn't correct
35 Incorrect 75 ms 6524 KB Output isn't correct
36 Correct 46 ms 5392 KB Output is correct
37 Correct 47 ms 5948 KB Output is correct
38 Incorrect 62 ms 6600 KB Output isn't correct
39 Incorrect 67 ms 6220 KB Output isn't correct
40 Correct 53 ms 5236 KB Output is correct
41 Correct 57 ms 5384 KB Output is correct
42 Incorrect 65 ms 7216 KB Output isn't correct
43 Correct 63 ms 5756 KB Output is correct
44 Correct 81 ms 8836 KB Output is correct
45 Correct 66 ms 7024 KB Output is correct
46 Correct 16 ms 3852 KB Output is correct
47 Correct 58 ms 5740 KB Output is correct
48 Correct 58 ms 6100 KB Output is correct
49 Incorrect 60 ms 5052 KB Output isn't correct
50 Correct 62 ms 7784 KB Output is correct
51 Incorrect 63 ms 5236 KB Output isn't correct
52 Correct 83 ms 9000 KB Output is correct
53 Correct 81 ms 9036 KB Output is correct
54 Correct 46 ms 5568 KB Output is correct
55 Incorrect 99 ms 10736 KB Output isn't correct
56 Correct 83 ms 8740 KB Output is correct
57 Correct 73 ms 6348 KB Output is correct
58 Incorrect 82 ms 8476 KB Output isn't correct
59 Correct 66 ms 6308 KB Output is correct
60 Correct 77 ms 7888 KB Output is correct
61 Correct 57 ms 5588 KB Output is correct
62 Correct 73 ms 5580 KB Output is correct
63 Correct 61 ms 5708 KB Output is correct
64 Correct 34 ms 5268 KB Output is correct
65 Correct 49 ms 4716 KB Output is correct
66 Correct 70 ms 6756 KB Output is correct
67 Correct 72 ms 6732 KB Output is correct
68 Correct 60 ms 5708 KB Output is correct
69 Incorrect 55 ms 6100 KB Output isn't correct
70 Correct 51 ms 5260 KB Output is correct
71 Incorrect 78 ms 9296 KB Output isn't correct
72 Correct 42 ms 5320 KB Output is correct
73 Correct 56 ms 5836 KB Output is correct
74 Correct 47 ms 5564 KB Output is correct
75 Incorrect 101 ms 8928 KB Output isn't correct
76 Correct 83 ms 8044 KB Output is correct
77 Correct 68 ms 6496 KB Output is correct
78 Incorrect 95 ms 8176 KB Output isn't correct
79 Correct 52 ms 5808 KB Output is correct
80 Correct 116 ms 9708 KB Output is correct
81 Correct 59 ms 5576 KB Output is correct
82 Correct 83 ms 8912 KB Output is correct
83 Incorrect 67 ms 5268 KB Output isn't correct
84 Correct 65 ms 5596 KB Output is correct
85 Incorrect 116 ms 9312 KB Output isn't correct
86 Incorrect 26 ms 2376 KB Output isn't correct
87 Correct 67 ms 6536 KB Output is correct
88 Correct 87 ms 7604 KB Output is correct
89 Correct 63 ms 6192 KB Output is correct
90 Correct 51 ms 5480 KB Output is correct
91 Correct 55 ms 5760 KB Output is correct
92 Correct 77 ms 8188 KB Output is correct
93 Correct 65 ms 5324 KB Output is correct
94 Correct 56 ms 5580 KB Output is correct
95 Incorrect 60 ms 5688 KB Output isn't correct
96 Correct 72 ms 7856 KB Output is correct
97 Incorrect 91 ms 8052 KB Output isn't correct
98 Correct 61 ms 5804 KB Output is correct
99 Correct 66 ms 5244 KB Output is correct
100 Correct 81 ms 9444 KB Output is correct
101 Incorrect 99 ms 9336 KB Output isn't correct
102 Incorrect 61 ms 6720 KB Output isn't correct