답안 #210744

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210744 2020-03-18T09:48:09 Z mhy908 Lamps (JOI19_lamps) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortvec(x) sort(all(x))
#define compress(x) x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=1987654321987654321;
const int inf=2000000000;
LL dp[1000010][4];
int n;
char str1[1000010], str2[1000010];
char alter(char c, int qu){
    if(qu==1)return '0';
    if(qu==2)return '1';
    return c;
}
int main(){
    scanf("%d", &n);
    scanf("%s", str1+1);
    scanf("%s", str2+1);
    for(int i=1; i<=n; i++)dp[i][1]=dp[i][2]=dp[i][3]=inf;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=3; j++){
            for(int k=1; k<=3; k++){
                int temp=dp[i-1][j];
                if(j!=k&&k!=2)temp++;
                if((i==1||alter(a[i-1], j)==b[i-1])&&alter(a[i], k)!=b[i])temp++;
                dp[i][k]=min(dp[i][k], temp);
            }
        }
    }
    printf("%d", min(min(dp[n][1], dp[n][2]), dp[n][3]));
}

Compilation message

lamp.cpp: In function 'int main()':
lamp.cpp:35:33: error: 'a' was not declared in this scope
                 if((i==1||alter(a[i-1], j)==b[i-1])&&alter(a[i], k)!=b[i])temp++;
                                 ^
lamp.cpp:35:45: error: 'b' was not declared in this scope
                 if((i==1||alter(a[i-1], j)==b[i-1])&&alter(a[i], k)!=b[i])temp++;
                                             ^
lamp.cpp:36:44: error: no matching function for call to 'min(LL&, int&)'
                 dp[i][k]=min(dp[i][k], temp);
                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from lamp.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
lamp.cpp:36:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 dp[i][k]=min(dp[i][k], temp);
                                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from lamp.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
lamp.cpp:36:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 dp[i][k]=min(dp[i][k], temp);
                                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lamp.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
lamp.cpp:36:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 dp[i][k]=min(dp[i][k], temp);
                                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lamp.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
lamp.cpp:36:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 dp[i][k]=min(dp[i][k], temp);
                                            ^
lamp.cpp:40:56: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
     printf("%d", min(min(dp[n][1], dp[n][2]), dp[n][3]));
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
lamp.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
lamp.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str1+1);
     ~~~~~^~~~~~~~~~~~~~
lamp.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", str2+1);
     ~~~~~^~~~~~~~~~~~~~