제출 #61307

#제출 시각아이디문제언어결과실행 시간메모리
61307dukati8미술 수업 (IOI13_artclass)C++14
컴파일 에러
0 ms0 KiB
#include <stdio.h> #include "artclass.h" #include <bits/stdc++.h> #include <iostream> using namespace std; #define rep(i,a,b) for(int i=a;i<int(b);i++) int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { //Check sum of all pixels double totr,totb,totg; totr=0;totb=0;totg=0; rep (i,0,H) { rep (j,0,W) { totr+=R[i][j]; totb+=B[i][j]; totg+=G[i][j]; } } totr/=H*W; totb/=H*W; totg/=H*W; double hi=max(totr,max(totg,totb)); double lo=min(totr,min(totg,totb)); double med=totr+totg+totb-hi-lo; double diff1=hi-med; double diff2=med-lo; //cout << totr << " " << totg << " " << totb<<endl; if (lo*1.3>hi) return 3; if (abs(diff1-diff2)<min(diff1,diff2)) return 3; if (lo*3<hi) return 4; if (1.2*totb<totg && 1.3*totb<totr && totg+totr+totb<350) return 2; if (totg+totr+totb<500) return 1; //Check for 10*10 square that is relatively white return 1; } static int DIM[2]; static int R[500][500]; static int G[500][500]; static int B[500][500]; int main() { FILE *in = fopen("artclass.txt", "r"); if(in == NULL) { puts("Failed to open input file (artclass.txt)."); return 0; } if(fscanf(in, "%d%d", DIM, DIM+1) != 2) { printf("Line 1: H, W must be integers\n"); return 0; } if(DIM[0] < 100 || 500 < DIM[0]) { printf("Line 1: 100 <= H <= 500\n"); return 0; } if(DIM[1] < 100 || 500 < DIM[1]) { printf("Line 1: 100 <= W <= 500\n"); return 0; } for(int i = 0; i< DIM[0]; i++) { for(int j = 0; j < DIM[1]; j++) { if(fscanf(in, "%d%d%d", &R[i][j], &G[i][j], &B[i][j]) != 3) { printf("Line %d: R[i][j], G[i][j], B[i][j] must be integers", i*DIM[1]+j+2, i, j); return 0; } if(R[i][j] < 0 || 255 < R[i][j]) { printf("Line %d: 0 <= R[%d][%d] <= 255", i*DIM[1]+j+2, i, j); return 0; } if(G[i][j] < 0 || 255 < G[i][j]) { printf("Line %d: 0 <= G[%d][%d] <= 255", i*DIM[1]+j+2, i, j); return 0; } if(B[i][j] < 0 || 255 < B[i][j]) { printf("Line %d: 0 <= B[%d][%d] <= 255", i*DIM[1]+j+2, i, j); return 0; } } } printf("%d\n", style(DIM[0], DIM[1], R, G, B)); return 0; }

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

artclass.cpp: In function 'int main()':
artclass.cpp:68:96: warning: too many arguments for format [-Wformat-extra-args]
                printf("Line %d: R[i][j], G[i][j], B[i][j] must be integers", i*DIM[1]+j+2, i, j);
                                                                                                ^
/tmp/cc7q1ulf.o: In function `main':
artclass.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc7KM453.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status