답안 #104592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104592 2019-04-08T09:55:42 Z antimirage Lamps (JOI19_lamps) C++14
컴파일 오류
0 ms 0 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

int n;//, dp[N][N][2], pref[N][2], fl[N];

string a, b;

//int calc (int l, int r, int type){
//
//      if (l > r) return 0;
//
//      if (dp[l][r][type] < 1e9) return dp[l][r][type];
//
//      int &ans = dp[l][r][type];
//
//      if (type == 0){
//
//            if ( a[l] == b[l] ){
//                  ans = calc(l + 1, r, type);
//                  return ans;
//            }
//            if ( a[r] == b[r] ){
//                  ans = calc(l, r - 1, type);
//                  return ans;
//            }
//
//            ans = min(ans, pref[r][0] );
//      }
//}

main(){

      memset( dp, 0x3f3f3f3f, sizeof(dp) );

      cin >> n >> a >> b;

      a = ' ' + a;
      b = ' ' + b;

      for (int i = 1; i <= n; i++){

            if (i > 1 && a[i] != a[i - 1])
                  fl[i]++;

            fl[i] += fl[i - 1];

            if (b[i] != b[i - 1])
                  pref[i][ b[i] - 48 ] = 1;

            pref[i][0] += pref[i - 1][0];
            pref[i][1] += pref[i - 1][1];
      }
      assert(fl[n] == 0);

      cout << pref[n][1] << endl;

//      calc(1, n, 0);
//      calc(1, n, 1);
//
//      cout << min( dp[1][n][0], dp[1][n][1] ) << endl;
}

Compilation message

lamp.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
lamp.cpp: In function 'int main()':
lamp.cpp:36:15: error: 'dp' was not declared in this scope
       memset( dp, 0x3f3f3f3f, sizeof(dp) );
               ^~
lamp.cpp:46:19: error: 'fl' was not declared in this scope
                   fl[i]++;
                   ^~
lamp.cpp:48:13: error: 'fl' was not declared in this scope
             fl[i] += fl[i - 1];
             ^~
lamp.cpp:51:19: error: 'pref' was not declared in this scope
                   pref[i][ b[i] - 48 ] = 1;
                   ^~~~
lamp.cpp:51:19: note: suggested alternative: 'dremf'
                   pref[i][ b[i] - 48 ] = 1;
                   ^~~~
                   dremf
lamp.cpp:53:13: error: 'pref' was not declared in this scope
             pref[i][0] += pref[i - 1][0];
             ^~~~
lamp.cpp:53:13: note: suggested alternative: 'dremf'
             pref[i][0] += pref[i - 1][0];
             ^~~~
             dremf
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from lamp.cpp:1:
lamp.cpp:56:14: error: 'fl' was not declared in this scope
       assert(fl[n] == 0);
              ^
lamp.cpp:58:15: error: 'pref' was not declared in this scope
       cout << pref[n][1] << endl;
               ^~~~
lamp.cpp:58:15: note: suggested alternative: 'dremf'
       cout << pref[n][1] << endl;
               ^~~~
               dremf