Submission #764016

#TimeUsernameProblemLanguageResultExecution timeMemory
764016ymmArt Class (IOI13_artclass)C++17
100 / 100
56 ms3292 KiB
#include "artclass.h"

#include <bits/stdc++.h>
#define Loop(x, l, r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll ,ll > pll;
using namespace std;

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
	ll sumdif = 0;
	ll cntbig = 0;
	Loop (i,0,H) Loop (j,0,W) {
		for (auto [x, y] : {pii{0, -1}, {0, 1}, {-1, 0}, {1, 0}}) {
			int ii = i+x, jj = j+y;
			if (ii < 0 || H <= ii || jj < 0 || W <= jj)
				continue;
			int dif = 0;
			for (auto X : {R, G, B})
				dif += abs(X[ii][jj] - X[i][j]);
			if (dif >= 48)
				cntbig++;
			else
				sumdif += dif;
		}
	}
	double a = (double)sumdif/(H*W);
	double b = (double)cntbig/(H*W);
	if (a > 50)
		return 2;
	if (b < 0.05 || a < 20 && b < 0.08)
		return 4;
	if (b < 1)
		return 1;
	return 3;
	cout << fixed << setprecision(9);
	cout << a << ' ' << b << '\n';
	return 0;
}

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:32:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   32 |  if (b < 0.05 || a < 20 && b < 0.08)
      |                  ~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...