답안 #895501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895501 2023-12-30T06:29:01 Z Shayan86 무지개나라 (APIO17_rainbow) C++14
컴파일 오류
0 ms 0 KB
#include "rainbow.h"
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// Ofast, O0, O1, O2, O3, unroll-loops, fast-math, trapv
 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
 
#define Mp          make_pair
#define sep         ' '
#define endl        '\n'
#define F	        first
#define S	        second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define kill(res)	cout << res << '\n', exit(0);
#define set_dec(x)	cout << fixed << setprecision(x);
#define fast_io     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io     freopen("input.txt", "r", stdin) ; freopen("output.txt", "w", stdout);
 
#define lid (id<<1)
#define rid (lid|1)
#define mid ((l+r)>>1)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll N = 2e5 + 50;
const ll Mod = 1e9 + 7;
 
struct segment{
    vector<int> idx[N], seg[N*4];
 
    void build(int l = 0, int r = N, int id = 1){
        if(l+1 == r){
            seg[id] = idx[l];
            sort(all(seg[id]));
            seg[id].resize(unique(all(seg[id])) - seg[id].begin());
            return;
        }
 
        build(l, mid, lid);
        build(mid, r, rid);
 
        seg[id].resize(seg[lid].size() + seg[rid].size());
        merge(all(seg[lid]), all(seg[rid]), seg[id].begin());
    }
 
    int get(int ql, int qr, int dwn, int up, int l = 0, int r = N, int id = 1){
        if(ql <= l && r <= qr){
            int x1 = lower_bound(all(seg[id]), up) - seg[id].begin();
            int x2 = lower_bound(all(seg[id]), dwn) - seg[id].begin();
            return x2 - x1;
        }
        if(qr <= l || r <= ql) return 0;
        return get(ql, qr, dwn, up, l, mid, lid) + get(ql, qr, dwn, up, mid, r, rid);
    }
} pnt, vert, horiz, riv;
 
int R, C, sr, sc, M, x0 = N, y0 = N, x1, y1;
string s;
 
void add(int x, int y){
    riv.idx[x].pb(y);
    vert.idx[x-1].pb(y);
    vert.idx[x].pb(y);
    horiz.idx[x].pb(y-1);
    horiz.idx[x].pb(y);
    pnt.idx[x-1].pb(y-1);
    pnt.idx[x-1].pb(y);
    pnt.idx[x].pb(y-1);
    pnt.idx[x].pb(y);
    x0 = min(x0, x);
    x1 = max(x1, x);
    y0 = min(y0, y);
    y1 = max(y1, y);
}
 
void init(int _R, int _C, int _sr, int _sc, int _M, char *S){
    R = _R; C = _C; sr = _sr; sc = _sc; M = _M; s = S;
 
    int x = sc, y = sr; add(x, y);
    for(int i = 0; i < M; i++){
        if(s[i] == 'N') y--;
        else if(s[i] == 'S') y++;
        else if(s[i] == 'E') x++;
        else x--;
        add(x, y);
    }
 
    pnt.build(); vert.build(); horiz.build(); riv.build();
}
 
int colour(int ar, int ac, int br, int bc){
    ll m = vert.get(ac, bc, br + 1, ar) + horiz.get(ac, bc + 1, br, ar) + 2 * (br - ar + 1 + bc - ac + 1);
    ll n = pnt.get(ac, bc, br, ar) + 2 * (br - ar + 1 + bc - ac + 1);
    ll r = riv.get(ac, bc + 1, br + 1, ar);
    ll x = (ac < x0 && x1 < bc && ar < y0 && br < y1);
    ll res = m - n + 1 - r + x;
    return res;
}

Compilation message

rainbow.cpp:102:2: error: extended character   is not valid in an identifier
  102 |     ll x = (ac < x0 && x1 < bc && ar < y0 && br < y1);
      |  ^
rainbow.cpp:102:5: error: extended character   is not valid in an identifier
  102 |     ll x = (ac < x0 && x1 < bc && ar < y0 && br < y1);
      |    ^
rainbow.cpp:64:30: error: 'int y0' redeclared as different kind of entity
   64 | int R, C, sr, sc, M, x0 = N, y0 = N, x1, y1;
      |                              ^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from rainbow.cpp:3:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:220:1: note: previous declaration 'double y0(double)'
  220 | __MATHCALL (y0,, (_Mdouble_));
      | ^~~~~~~~~~
rainbow.cpp:64:42: error: 'int y1' redeclared as different kind of entity
   64 | int R, C, sr, sc, M, x0 = N, y0 = N, x1, y1;
      |                                          ^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from rainbow.cpp:3:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration 'double y1(double)'
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
rainbow.cpp: In function 'void add(int, int)':
rainbow.cpp:79:19: error: no matching function for call to 'min(double (&)(double) throw (), int&)'
   79 |     y0 = min(y0, y);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
rainbow.cpp:79:19: note:   deduced conflicting types for parameter 'const _Tp' ('double(double)' and 'int')
   79 |     y0 = min(y0, y);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
rainbow.cpp:79:19: note:   deduced conflicting types for parameter 'const _Tp' ('double(double)' and 'int')
   79 |     y0 = min(y0, y);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
rainbow.cpp:79:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double) throw ()' {aka 'double (*)(double)'}
   79 |     y0 = min(y0, y);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
rainbow.cpp:79:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double) throw ()' {aka 'double (*)(double)'}
   79 |     y0 = min(y0, y);
      |                   ^
rainbow.cpp:80:19: error: no matching function for call to 'max(double (&)(double) throw (), int&)'
   80 |     y1 = max(y1, y);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
rainbow.cpp:80:19: note:   deduced conflicting types for parameter 'const _Tp' ('double(double)' and 'int')
   80 |     y1 = max(y1, y);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
rainbow.cpp:80:19: note:   deduced conflicting types for parameter 'const _Tp' ('double(double)' and 'int')
   80 |     y1 = max(y1, y);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
rainbow.cpp:80:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double) throw ()' {aka 'double (*)(double)'}
   80 |     y1 = max(y1, y);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rainbow.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
rainbow.cpp:80:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double) throw ()' {aka 'double (*)(double)'}
   80 |     y1 = max(y1, y);
      |                   ^
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:102:2: error: '\U000000a0' was not declared in this scope
  102 |     ll x = (ac < x0 && x1 < bc && ar < y0 && br < y1);
      |  ^
rainbow.cpp:103:30: error: 'x' was not declared in this scope
  103 |     ll res = m - n + 1 - r + x;
      |                              ^