제출 #69866

#제출 시각아이디문제언어결과실행 시간메모리
69866FLDutchman미술 수업 (IOI13_artclass)C++14
0 / 100
134 ms66560 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; typedef int INT; #define FOR(i,l,r) for(int i = (l); i < (r); i++) #define fst first #define snd second #define pb push_back #define mp make_pair #define V vector #define int long long typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<vi> vvi; typedef vector<ii> vii; const int NMAX = 1e5+10; double sqr(double x) {return x * x;} struct color{ double r, g, b; double l; color (){} color (int r, int g, int b) : r(r), g(g), b(b) {l = sqrt(r*r + g*g + b*b);} int operator- (const color &c) { //cerr<<r/l<<endl; return abs(l-c.l); //abs(r/l-c.r/c.l) + abs(g/l-c.g/c.l) + abs(b/l-c.b/c.l); } }; V<V<color>> canvas; int H, W; double diff(){ double tot = 0; double div = 0; FOR(i, 0, H) FOR(j, 0, W){ if(i > 0) {tot += canvas[i][j] - canvas[i-1][j]; div++;} if(j > 0) {tot += canvas[i][j] - canvas[i][j-1]; div++;} } return tot / div; } double diff(string s){ ifstream fin(s); fin >> H >> W; canvas.assign(H, V<color>(W)); FOR(i, 0, H) FOR(j, 0, W){ int r,g,b; fin>>r>>g>>b; canvas[i][j] = {r, g, b}; } double tot = 0; double div = 0; FOR(i, 0, H) FOR(j, 0, W){ if(i > 0) {tot += canvas[i][j] - canvas[i-1][j]; div++;} if(j > 0) {tot += canvas[i][j] - canvas[i][j-1]; div++;} } return tot / div; } INT style(INT h, INT w, INT R[500][500], INT G[500][500], INT B[500][500]) { H=h; W=w; canvas.assign(H, V<color>(W)); FOR(i, 0, H) FOR(j, 0, W){ canvas[i][j] = {R[j][i], G[j][i], B[j][i]}; } int k = 10 * diff(); if(k <= 40) return 4; if(k <= 115) return 1; if(k <= 300) return 2; return 3; } /* signed main(){ cout << setprecision(3); FOR(style, 1, 5) { FOR(i, 1, 10) cout << (int) (10000*diff("style-"+to_string(style)+"-"+to_string(i)+".txt") ) << "\t"; cout << endl; } }*/
#Verdict Execution timeMemoryGrader output
Fetching results...