제출 #106068

#제출 시각아이디문제언어결과실행 시간메모리
106068Alexa2001Lamps (JOI19_lamps)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e6 + 5; static void min_to(int &x, int y) { if(x>y) x=y; } int dp[Nmax][6], apply[2][6], go[6][6]; int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); int n, i, j, k; string A, B; cin >> n; cin >> A >> B; for(auto &it : A) it -= '0'; for(auto &it : B) it -= '0'; for(i=0; i<6; ++i) for(j=0; j<6; ++j) go[i][j] = (i/3 == 1 && j/3 == 0) + (i%3 != 2 && j%3 != i%3); for(i=0; i<2; ++i) for(j=0; j<6; ++j) apply[i][j] = (j%3 == 2 ? i : j%3) ^ (j/3); for(i=0; i<=n; ++i) for(j=0; j<6; ++j) dp[i][j] = 1e9; dp[0][2] = 0; for(i=0; i<n; ++i) for(k=0; k<6; ++k) if(apply[A[i]][k] == B[i]) for(j=0; j<6; ++j) min_to(dp[i+1][k], dp[i][j] + go[j][k]); int ans = 1e9; for(i=0; i<6; ++i) min_to(ans, dp[n][i] + go[i][2]); cout << ans << '\n'; return 0; }

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

lamp.cpp: In function 'int main()':
lamp.cpp:31:13: error: reference to 'apply' is ambiguous
             apply[i][j] = (j%3 == 2 ? i : j%3) ^ (j/3);
             ^~~~~
lamp.cpp:9:18: note: candidates are: int apply [2][6]
 int dp[Nmax][6], apply[2][6], go[6][6];
                  ^~~~~
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from lamp.cpp:1:
/usr/include/c++/7/tuple:1668:5: note:                 template<class _Fn, class _Tuple> constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&)
     apply(_Fn&& __f, _Tuple&& __t)
     ^~~~~
lamp.cpp:41:16: error: reference to 'apply' is ambiguous
             if(apply[A[i]][k] == B[i])
                ^~~~~
lamp.cpp:9:18: note: candidates are: int apply [2][6]
 int dp[Nmax][6], apply[2][6], go[6][6];
                  ^~~~~
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from lamp.cpp:1:
/usr/include/c++/7/tuple:1668:5: note:                 template<class _Fn, class _Tuple> constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&)
     apply(_Fn&& __f, _Tuple&& __t)
     ^~~~~