제출 #61370

#제출 시각아이디문제언어결과실행 시간메모리
61370istlemin미술 수업 (IOI13_artclass)C++14
93 / 100
544 ms9552 KiB
#include "artclass.h" #include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i<int(b);++i) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define trav(a,c) for(auto a: c) typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; ll h,w; vector<vi> r,g,b; ll sumDiff(ll dh,ll dw){ ll sum = 0; rep(i,0,h){ rep(j,0,w){ if(i+dh<h){ sum += abs(r[i][j]-r[i+dh][j]); sum += abs(g[i][j]-g[i+dh][j]); sum += abs(b[i][j]-b[i+dh][j]); } if(j+dw<w){ sum += abs(r[i][j]-r[i][j+dw]); sum += abs(g[i][j]-g[i][j+dw]); sum += abs(b[i][j]-b[i][j+dw]); } } } return sum; } bool hasWhiteSquare(ll sh,ll sw){ rep(i1,0,h-sh+1) rep(j1,0,w-sw+1){ bool allWhite = true; rep(i,i1,i1+sh) rep(j,j1,j1+sw){ allWhite &= (r[i][j]>=220); allWhite &= (g[i][j]>=220); allWhite &= (b[i][j]>=220); } if(allWhite) return true; } return false; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h = H; w = W; r.resize(h,vi(w)); g.resize(h,vi(w)); b.resize(h,vi(w)); rep(i,0,h) rep(j,0,w){ r[i][j] = R[i][j]; g[i][j] = G[i][j]; b[i][j] = B[i][j]; } double sumD = sumDiff(5,5)/double(w)/double(h); //cout<<sumD<<endl; if(sumD<40) return 4; if(sumD>200) return 3; if(hasWhiteSquare(20,20)){ return 1; } return 2; /*int numGreen = 0; for (int x = 0; x < W; x++) { for (int y = 0; y < H; y++) { int r = R[y][x]; int g = G[y][x]; int b = B[y][x]; double pHue; if (r > g && r > b) pHue = (double)(g - b) / (r - std::min(g, b)); else if (g > r && g > b) pHue = 2.0 + (double)(b - r) / (g - std::min(b, r)); else if (b > r && b > g) pHue = 4.0 + (double)(r - g) / (b - std::min(r, g)); if (pHue < 0) pHue += 360 / 60; pHue *= 60; if (pHue > 60 && pHue < 160) numGreen++; } } double pGreen = (double)numGreen / (double)(W * H); cout<<pGreen<<endl; if (pGreen > 0.2) return 2; return 1;*/ } /* vi getDiffs(ll dh,ll dw){ vi diffs(256); rep(i,0,h){ rep(j,0,w){ if(i+dh<h){ diffs[abs(r[i][j]-r[i+dh][j])]++; diffs[abs(g[i][j]-g[i+dh][j])]++; diffs[abs(b[i][j]-b[i+dh][j])]++; } if(j+dw<w){ diffs[abs(r[i][j]-r[i][j+dw])]++; diffs[abs(g[i][j]-g[i][j+dw])]++; diffs[abs(b[i][j]-b[i][j+dw])]++; } } } return diffs; } bool hasWhiteSquare(ll sh,ll sw){ rep(i1,0,h-sh+1) rep(j1,0,w-sw+1){ bool allWhite = true; rep(i,i1,i1+sh) rep(j,j1,j1+sw){ allWhite &= (r[i][j]>=200); allWhite &= (g[i][j]>=200); allWhite &= (b[i][j]>=200); } if(allWhite) return true; } return false; } ll numSquares(ll sh,ll sw){ ll ans = 0; rep(i1,0,h-sh+1) rep(j1,0,w-sw+1){ double sumR = 0; double sumG = 0; double sumB = 0; rep(i,i1,i1+sh) rep(j,j1,j1+sw){ sumR += r[i][j]; sumG += g[i][j]; sumB += b[i][j]; } sumR /= sh*sw; sumG /= sh*sw; sumB /= sh*sw; double stdR = 0; double stdG = 0; double stdB = 0; rep(i,i1,i1+sh) rep(j,j1,j1+sw){ stdR += (r[i][j]-sumR)*(r[i][j]-sumR); stdG += (r[i][j]-sumG)*(r[i][j]-sumG); stdB += (r[i][j]-sumB)*(r[i][j]-sumB); } if((stdR+stdG+stdB)/double(sh)/double(sw)<50){ ans++; } } return ans; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h = H; w = W; r.resize(h,vi(w)); g.resize(h,vi(w)); b.resize(h,vi(w)); ll greenSum = 0; ll rSum = 0; ll gSum = 0; ll bSum = 0; rep(i,0,h) rep(j,0,w){ rSum += r[i][j] = R[i][j]; gSum += g[i][j] = G[i][j]; bSum += b[i][j] = B[i][j]; } if(gSum>h*w*70) return 2; //cout<<numSquares(10,10)<<endl; //cout<<hasWhiteSquare(10,10)<<endl; return 1; /* vi segments = {0,10,30,80,150,256}; vi vals(segments.size()-1); vi diffs = getDiffs(1,1); rep(i,0,segments.size()-1){ rep(j,segments[i],segments[i+1]){ vals[i]+=diffs[j]; } //cout<<setw(10)<<vals[i]<<" "; } //cout<<endl; ll types[4][5] = {{1234884,80130,30000,10000,1000}, {505709,356111,67631,2924,50}, {201382,396123,228773,54461,1183}, {869868,17804,2046,300,0}}; ll mnErr = 1e18; ll best = 0; rep(i,0,4){ ll err = 0; vi facs = {1,5,100,100,1000}; rep(j,0,vals.size()){ ll currErr = 1e18; if(types[i][j]!=0) currErr = min(currErr,abs(types[i][j]-vals[i])*ll(1e4)/types[i][j]); cout<<currErr<<" "; currErr = abs(types[i][j]-vals[i]); cout<<currErr<<endl; currErr = abs(types[i][j]-vals[i])*facs[j]; err += currErr; } cout<<err<<endl; if(err<mnErr){ mnErr = err; best = i; } } cout<<best+1<<endl; return best+1; }*/

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp:195:2: warning: "/*" within comment [-Wcomment]
  /*
#Verdict Execution timeMemoryGrader output
Fetching results...