제출 #1129256

#제출 시각아이디문제언어결과실행 시간메모리
1129256Zbyszek99Ancient Machine 2 (JOI23_ancient2)C++20
컴파일 에러
0 ms0 KiB
#include "ancient2.h" #include <bits/stdc++.h> #define ll long long #define ld long double #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define size(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace std; //mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll rand(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; const int MAXN = 1000; struct equation { bitset<MAXN> eq; void operator^=(const equation& other) { eq ^= other.eq; } }; int n; equation eq[MAXN]; bool is_eq[MAXN]; int eq_count = 0; bool add_eq(equation new_eq, bool check = false) { rep(i,n) { if(new_eq.eq[i] == 1) { if(!is_eq[i]) { if(!check) { eq[i] = new_eq; is_eq[i] = 1; eq_count++; } // if(!check) cout << "git\n"; return 1; } new_eq ^= eq[i]; } } //cout << "boo\n"; return false; } string get_ans() { vi ans(n,0); for(int i = n-1; i >= 0; i--) { int sum = eq[i].eq[n]; for(int j = i+1; j < n; j++) { sum ^= (eq[i].eq[j]*ans[j]); } ans[i] = sum; } string ans_str; rep(i,n) ans_str += (char)('0' + ans[i]); return ans_str; } void get_eq_kth(int x, int mod) { equation ans; for(int i = mod; i < n; i += x) { // cout << i << " i\n"; ans.eq[i] = 1; } if(!add_eq(ans,true)) return; int m = x*2; vi a(m); vi b(m); // cout << mod << " mod\n"; for(int i = 0; i < x*2; i += 2) { if(i/2 == mod) { a[i] = (i+2)%(x*2); b[i] = (i+3)%(x*2); a[i+1] = (i+3)%(x*2); b[i+1] = (i+2)%(x*2); } else { a[i] = (i+2)%(x*2); b[i] = (i+2)%(x*2); a[i+1] = (i+3)%(x*2); b[i+1] = (i+3)%(x*2); } } int q = Query(m,a,b); if(q % 2 == 1) { ans.eq[n] = 1; } add_eq(ans); } equation get_first_num(int x) { equation ans; ans.eq[x] = 1; int m = x+3; vi a(m); vi b(m); rep(i,x) { a[i] = i+1; b[i] = i+1; } a[x] = m-2; b[x] = m-1; a[m-1] = m-1; b[m-1] = m-1; a[m-2] = m-2; b[m-2] = m-2; int q = Query(m,a,b); // cout << q << " q\n"; if(q == m-1) ans.eq[n] = 1; return ans; } string Solve(int N) { n = N; rep(i,100) { add_eq(get_first_num(i)); if(eq_count == n) return get_ans(); } rep2(k,1,1000) { rep(mod,k) { get_eq_kth(k,mod); if(eq_count == n) return get_ans(); } } }

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

ancient2.cpp: In function 'bool add_eq(equation, bool)':
ancient2.cpp:48:17: error: reference to 'is_eq' is ambiguous
   48 |             if(!is_eq[i])
      |                 ^~~~~
In file included from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/string:40,
                 from ancient2.h:1,
                 from ancient2.cpp:1:
/usr/include/c++/11/compare:320:3: note: candidates are: 'constexpr bool std::is_eq(std::partial_ordering)'
  320 |   is_eq(partial_ordering __cmp) noexcept
      |   ^~~~~
ancient2.cpp:39:6: note:                 'bool is_eq [1000]'
   39 | bool is_eq[MAXN];
      |      ^~~~~
ancient2.cpp:53:21: error: reference to 'is_eq' is ambiguous
   53 |                     is_eq[i] = 1;
      |                     ^~~~~
In file included from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/string:40,
                 from ancient2.h:1,
                 from ancient2.cpp:1:
/usr/include/c++/11/compare:320:3: note: candidates are: 'constexpr bool std::is_eq(std::partial_ordering)'
  320 |   is_eq(partial_ordering __cmp) noexcept
      |   ^~~~~
ancient2.cpp:39:6: note:                 'bool is_eq [1000]'
   39 | bool is_eq[MAXN];
      |      ^~~~~
ancient2.cpp: In function 'std::string Solve(int)':
ancient2.cpp:161:1: warning: control reaches end of non-void function [-Wreturn-type]
  161 | }
      | ^