제출 #573719

#제출 시각아이디문제언어결과실행 시간메모리
573719Theo830미술 수업 (IOI13_artclass)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll INF = 1e9+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<ll> distr; ll rnd(ll a, ll b){return distr(rng)%(b-a+1)+a;} #include "artclass.h" /* #ifndef __ARTCLASS_H__ #define __ARTCLASS_H__ #ifdef __cplusplus extern "C" { #endif int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]); #ifdef __cplusplus } #endif #endif #include <stdio.h> 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; } */ int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { ll n = H,m = W; ll posa = (n * m + 3) / 4; ll ans; set<ll>ex; ll prasina = 0; ll aspro = 0; f(i,0,n){ f(j,0,m){ ex.insert(R[i][j] + 256 * G[i][j] + 256 * 256 * B[i][j]); if(G[i][j] >= 50 && max(R[i][j],B[i][j]) <= 20){ prasina++; } if(max(G[i][j],R[i][j],B[i][j]) <= 5){ aspro++; } } } if(posa >= ex.size()){ if(prasina >= ex.size()){ ans = 2; } else{ ans = 3; } } else{ if(apsro >= posa){ ans = 1; } else{ ans = 4; } } return ans; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:112:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |     if(posa >= ex.size()){
      |        ~~~~~^~~~~~~~~~~~
artclass.cpp:113:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |          if(prasina >= ex.size()){
      |             ~~~~~~~~^~~~~~~~~~~~
artclass.cpp:121:12: error: 'apsro' was not declared in this scope; did you mean 'aspro'?
  121 |         if(apsro >= posa){
      |            ^~~~~
      |            aspro
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from artclass.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
artclass.cpp:107:43:   required from here
/usr/include/c++/10/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~