제출 #1122526

#제출 시각아이디문제언어결과실행 시간메모리
1122526kirakosyanChessboard (IZhO18_chessboard)C++20
컴파일 에러
0 ms0 KiB
#include<algorithm> #include<iostream> #include<vector> #include<string> #include<random> #include<cmath> #include<stack> #include<map> #include <iomanip> #include <queue> #include <set> using namespace std; using ll = long long; using ull = unsigned long long; ll mod = 1e9 + 7; ll pv(ll a, ll b) { if (b == 0)return 1; ll res = (pv(a, b / 2)); if (b % 2) { return (((res * res) % mod) * (a % mod)) % mod; } else { return (res * res) % mod; } } ll gcd(ll n1, ll n2) { if (n2 != 0) return gcd(n2, n1 % n2); else return n1; } void solve() { int n, k1; cin >> n >> k1; int baj = 0; for (int i = 1; i <= n; i++) { if (n % i == 0)baj++; } if (baj == 2) { //cout << "APER" << endl; ll sev = 0, hop = 0, sev1 = 0, hop1 = 0; for (ll i = 0; i < k1; i++) { ll x, y, x1, y1; cin >> x >> y >> x1 >> y1; //st.insert(x * n + y); if (x % 2 == 1 && y % 2 == 0) { sev++; } else if (x % 2 == 0 && y % 2 == 1) { sev++; } else hop++; if (x % 2 == 1 && y % 2 == 1) { sev1++; } else if (x % 2 == 0 && y % 2 == 0) { sev1++; } else hop1++; } ll aper = (n * n); ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 }); cout << mn << endl; return; } // global depq vector<vector<int>>pref(n + 1, vector<int>(n + 1)); for (int i = 0; i < k1; i++) { int x, y, x1, y1; cin >> x >> y >> x1 >> y1; pref[x][y]++; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { pref[i][j] += (pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1]); } } int cnt = 0, mn = 1e9; for (int k = 1; k < n; k++) { if (n % k == 0) { int ans1 = 0; for (int i = k; i <= n; i += k) { if (cnt % 2 == 0) { int cnt1 = 0; for (int j = k; j <= n; j += k) { int qarakusi = 0; if (cnt1 % 2 == 0) { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (k * k - qarakusi); } else { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (qarakusi); } cnt1++; } } else { int cnt1 = 0; for (int j = k; j <= n; j += k) { int qarakusi = 0; if (cnt1 % 2 == 1) { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (k * k - qarakusi); } else { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (qarakusi); } cnt1++; } } cnt++; } mn = min(mn, ans1); } } cnt = 0; for (int k = 1; k < n; k++) { if (n % k == 0) { int ans1 = 0; for (int i = k; i <= n; i += k) { if (cnt % 2 == 1) { int cnt1 = 0; for (int j = k; j <= n; j += k) { int qarakusi = 0; if (cnt1 % 2 == 0) { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (k * k - qarakusi); } else { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (qarakusi); } cnt1++; } } else { int cnt1 = 0; for (int j = k; j <= n; j += k) { int qarakusi = 0; if (cnt1 % 2 == 1) { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (k * k - qarakusi); } else { qarakusi = pref[i][j] - pref[i - k][j] - pref[i][j - k] + pref[i - k][j - k]; ans1 += (qarakusi); } cnt1++; } } cnt++; } mn = min(mn, ans1); } } cout << mn << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin.tie(nullptr); ll _ = 1; //cin >> _; while (_--) { solve(); } }

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

chessboard.cpp: In function 'void solve()':
chessboard.cpp:66:20: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   66 |         ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 });
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:61,
                 from chessboard.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:
chessboard.cpp:66:20: note:   candidate expects 2 arguments, 1 provided
   66 |         ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 });
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:61,
                 from chessboard.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:
chessboard.cpp:66:20: note:   candidate expects 3 arguments, 1 provided
   66 |         ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 });
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from chessboard.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:
chessboard.cpp:66:20: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'int')
   66 |         ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 });
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from chessboard.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:
chessboard.cpp:66:20: note:   deduced conflicting types for parameter '_Tp' ('long long int' and 'int')
   66 |         ll mn = min({ (aper / 2 - sev) + hop, ((aper + 1) / 2 - sev1) + hop1,n * n - k1 });
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~