제출 #1193503

#제출 시각아이디문제언어결과실행 시간메모리
1193503InvMODRelativnost (COCI15_relativnost)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define vi vector<int> #define pi pair<int,int> #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define compact(v) (v).erase(unique(all(v)), (v).end()) template<class T> using upq = priority_queue<T, vector<T>, greater<T>>; template<class T> int lwrbound(const vector<T>& a, const T& b, const int s = 0){return int(lower_bound(s + all(a), b) - a.begin());} template<class T> int uprbound(const vector<T>& a, const T& b, const int s = 0){return int(upper_bound(s + all(a), b) - a.begin());} #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define ROF(i, a, b) for(int i = (a); i >= (b); i--) #define sumof(x) accumulate(all(x), 0ll) #define dbg(x) "[" << #x " = " << (x) << "]" #define el "\n" using ll = long long; using ld = long double; template<class T> bool ckmx(T& a, const T b){return (a < b ? a = b, true : false);} template<class T> bool ckmn(T& a, const T b){return (a > b ? a = b, true : false);} const int N = 2e5 + 5; const int MOD = 10007; const ll INF = numeric_limits<ll>::max() / 8; void add(int16_t& x, int y){ x += y; if(x >= MOD) x -= MOD; } int mul(int x, int y){ return x * y % MOD; } struct SMT{ struct Node{ vector<int16_t> dp; Node(int c = 0): dp(c + 1, 0) {} friend Node operator + (const Node& a, const Node& b){ int16_t c = sz(a.dp) - 1; Node ans(c); for(int i = 0; i <= c; i++){ for(int j = 0; j <= c; j++){ add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j])); } } return ans; } }; vector<Node> st; int trsz; SMT(int n = 0, int c = 0): trsz(n), st((n << 2 | 1), Node(c)) {} void update(int id, int l, int r, int x, int a, int b){ if(l == r){ st[id].dp[0] = b % MOD; st[id].dp[1] = a % MOD; } else{ int m = l+r>>1; if(x <= m) update(id << 1, l, m, x, a, b); else update(id << 1|1, m+1, r, x, a, b); st[id] = st[id << 1] + st[id << 1|1]; } } void update(int x, int a, int b){ update(1, 1, trsz, x, a, b); } int ans(){ return st[1].dp.back(); } }; void Main() { int n,C; cin >> n >> C; SMT st(n, C); vi a(n + 1), b(n + 1); FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; FOR(i, 1, n){ st.update(i, a[i], b[i]); } int q; cin >> q; while(q--){ int p; cin >> p >> a[p] >> b[p]; st.update(p, a[p], b[p]); cout << st.ans() << el; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } int t = 1; while(t--) Main(); return 0; }

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

relativnost.cpp: In function 'SMT::Node operator+(const SMT::Node&, const SMT::Node&)':
relativnost.cpp:57:35: error: no matching function for call to 'min(int, int16_t&)'
   57 |                     add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j]));
      |                                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from relativnost.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
relativnost.cpp:57:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int16_t' {aka 'short int'})
   57 |                     add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j]));
      |                                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from relativnost.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
relativnost.cpp:57:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int16_t' {aka 'short int'})
   57 |                     add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j]));
      |                                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from relativnost.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
relativnost.cpp:57:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                     add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j]));
      |                                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from relativnost.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
relativnost.cpp:57:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                     add(ans.dp[min(i + j, c)], mul(a.dp[i], b.dp[j]));
      |                                ~~~^~~~~~~~~~
relativnost.cpp: In function 'int32_t main()':
relativnost.cpp:119:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  119 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
relativnost.cpp:120:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  120 |         freopen(name".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~