Submission #280095

#TimeUsernameProblemLanguageResultExecution timeMemory
280095shayan_pArt Class (IOI13_artclass)C++14
62 / 100
85 ms6140 KiB
// And you curse yourself for things you never done

#include<bits/stdc++.h>
#include "artclass.h"

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double ld;

const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

int style(int n, int m, int R[500][500], int G[500][500], int B[500][500]) {
    ll sR = 0, sG = 0, sB = 0;
    ll green = 0;
    for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++)
	    sR+= R[i][j], sG+= G[i][j], sB+= B[i][j];
    double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m;
    auto calc_borders = [&](int eps, int cnt){
			    int borders = 0;
			    auto same = [&](int x, int y, int xx, int yy){
					    return (abs(R[x][y] - R[xx][yy]) <= eps) + (abs(G[x][y] - G[xx][yy]) <= eps) + (abs(B[x][y] - B[xx][yy]) <= eps) >= cnt;
					};    
			    for(int i = 0; i < n; i++)
				for(int j = 0; j < m-1; j++)
				    borders+= !same(i, j, i, j+1);
			    for(int i = 0; i < n-1; i++)
				for(int j = 0; j < m; j++)
				    borders+= !same(i, j, i+1, j);
			    return double(borders)/n/m;
			};
    auto calc_borders2 = [&](int eps, int cnt){
			    int borders = 0;
			    auto same = [&](int x, int y, int xx, int yy){
					    return (abs(R[x][y] - R[xx][yy]) <= eps) + (abs(G[x][y] - G[xx][yy]) <= eps) + (abs(B[x][y] - B[xx][yy]) <= eps) <= cnt;
					};    
			    for(int i = 0; i < n; i++)
				for(int j = 0; j < m-1; j++)
				    borders+= !same(i, j, i, j+1);
			    for(int i = 0; i < n-1; i++)
				for(int j = 0; j < m; j++)
				    borders+= !same(i, j, i+1, j);
			    return double(borders)/n/m;
			};    
    //    cout << calc_borders(60, 3) << endl;
    //    cout << RR << " " << GG << " " << BB << endl;
    if(calc_borders2(10, 2) <= 0.9)
	return 3;
    if(BB >= 100)
	return 1;
    if(calc_borders(70, 3) <= 0.003)
	return 4;
    return 2;
}

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:22:8: warning: unused variable 'green' [-Wunused-variable]
   22 |     ll green = 0;
      |        ^~~~~
artclass.cpp:26:12: warning: unused variable 'RR' [-Wunused-variable]
   26 |     double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m;
      |            ^~
artclass.cpp:26:35: warning: unused variable 'GG' [-Wunused-variable]
   26 |     double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m;
      |                                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...