# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
164217 | atoiz | 미술 수업 (IOI13_artclass) | C++14 | 113 ms | 9592 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <utility>
#include <tuple>
#include <climits>
#include <fstream>
#include <bitset>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <random>
#include <chrono>
#include <ios>
#include <iomanip>
#include <functional>
#include "artclass.h"
using namespace std;
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORA(i, a) for (auto &i : a)
#define FORB(i, a, b) for (int i = a; i >= b; --i)
#define SZ(a) ((int) a.size())
#define ALL(a) begin(a), end(a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define fi first
#define se second
vi getCnt(vvi R, vvi G, vvi B)
{
int H = SZ(R), W = SZ(R[0]);
vi cnt(768, 0);
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
if (i > 0) {
int dist = 0;
dist += abs(R[i][j] - R[i - 1][j]);
dist += abs(G[i][j] - G[i - 1][j]);
dist += abs(B[i][j] - B[i - 1][j]);
++cnt[dist];
}
if (j > 0) {
int dist = 0;
dist += abs(R[i][j] - R[i][j - 1]);
dist += abs(G[i][j] - G[i][j - 1]);
dist += abs(B[i][j] - B[i][j - 1]);
++cnt[dist];
}
}
}
return cnt;
}
ll getTotal(vi cnt)
{
ll ans = 0;
FOR(i, 0, SZ(cnt) - 1) ans += 1ll * i * cnt[i];
return ans;
}
double midDist(vvi R, vvi G, vvi B)
{
int H = SZ(R), W = SZ(R[0]);
double midR = 0, midG = 0, midB = 0;
FOR(i, 0, H - 1) FOR(j, 0, W - 1) {
midR += R[i][j];
midG += G[i][j];
midB += B[i][j];
}
midR /= H * W;
midG /= H * W;
midB /= H * W;
double total = 0;
FOR(i, 0, H - 1) FOR(j, 0, W - 1) {
total += abs(midR - R[i][j]);
total += abs(midG - G[i][j]);
total += abs(midB - B[i][j]);
}
return total / 1e7;
}
int cntSub(vi cnt, int from, int to)
{
return accumulate(cnt.begin() + from, cnt.begin() + to, 0);
}
ll totalSub(vi cnt, int from, int to)
{
ll ans = 0;
FOR(i, from, to) ans += cnt[i] * i;
return ans;
}
double avgSub(vi cnt, int from, int to)
{
return 1.0 * totalSub(cnt, from, to) / cntSub(cnt, from, to);
}
int style(int H, int W, int _R[500][500], int _G[500][500], int _B[500][500]) {
vvi R(H, vi(W));
vvi G(H, vi(W));
vvi B(H, vi(W));
FOR(i, 0, H - 1) FOR(j, 0, W - 1) {
R[i][j] = _R[i][j];
G[i][j] = _G[i][j];
B[i][j] = _B[i][j];
}
vi curCnt = getCnt(R, G, B);
double big_diff = 1.0 * accumulate(curCnt.begin() + 96, curCnt.end(), 0) / accumulate(ALL(curCnt), 0);
double huge_diff = 1.0 * accumulate(curCnt.begin() + 256, curCnt.end(), 0) / accumulate(ALL(curCnt), 0);
double deviation = midDist(R, G, B);
if (big_diff < 0.005 || (big_diff < 0.01 && deviation < 2)) return 4;
double avg_dist = 1.0 * getTotal(curCnt) / H / W;
double totalRGB = 0;
FOR(i, 0, H - 1) FOR(j, 0, W - 1) totalRGB += R[i][j] + G[i][j] + B[i][j];
totalRGB /= H * W;
if (avg_dist > 128 || (avg_dist > 96 && totalRGB > 256)) return 3;
double avg_same = avgSub(curCnt, 0, 31);
double same_ratio = (1.0 * accumulate(curCnt.begin(), curCnt.begin() + 16, 0) / accumulate(ALL(curCnt), 0));
int score = 0;
if (same_ratio < 0.5) score += 20;
if (same_ratio > 0.6) score -= 20;
if (totalRGB < 350) score += 10;
else score -= 10;
if (deviation < 3.5) score += 10;
else score -= 10;
if (avg_same > 11) score += 5;
else score -= 5;
if (avg_dist > 45) score += 1;
else score -= 1;
if (score > 0) return 2;
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |