제출 #140851

#제출 시각아이디문제언어결과실행 시간메모리
140851shafinalam새로운 문제 (POI11_roz)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second const int mxn = 1e6+5; typedef pair<int,int>pii; #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) #define all(v) v.begin(), v.end() vector<pii>arr[30]; pii tmp[mxn]; int main() { //input; //output; int n; scanf("%d", &n); char ch; for(int i = 0; i < n; i++) { scanf(" %c", &ch); arr[ch-'a'].push_back(make_pair(i, ch-'a')); } int ans = -1; for(int i = 0; i < 26; i++) { for(int r = 0; r < 26; r++) { if(i==r) continue; merge(all(arr[i]), all(arr[r]), back_inserter(tmp)); int k = arr[i].size()+arr[r].size(); int sum = 0, best = -(1<<30); for(int j = 0; j < k; j++) { if(tmp[j].ss==i) { sum++; best++; } else { best = sum-1; sum = max(sum-1, 0); } ans = max(ans, best); } } } printf("%d\n", ans); return 0; }

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

In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 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 roz.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h: In instantiation of 'class std::back_insert_iterator<std::pair<int, int> [1000005]>':
roz.cpp:34:53:   required from here
/usr/include/c++/7/bits/stl_iterator.h:487:7: error: 'std::pair<int, int> [1000005]' is not a class, struct, or union type
       operator=(const typename _Container::value_type& __value)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:494:7: error: 'std::pair<int, int> [1000005]' is not a class, struct, or union type
       operator=(typename _Container::value_type&& __value)
       ^~~~~~~~
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 roz.cpp:1:
/usr/include/c++/7/bits/stl_algo.h: In instantiation of '_OutputIterator std::__merge(_InputIterator1, _InputIterator1, _InputIterator2, _InputIterator2, _OutputIterator, _Compare) [with _InputIterator1 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _InputIterator2 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _OutputIterator = std::back_insert_iterator<std::pair<int, int> [1000005]>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/7/bits/stl_algo.h:4937:37:   required from '_OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter) [with _IIter1 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _IIter2 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _OIter = std::back_insert_iterator<std::pair<int, int> [1000005]>]'
roz.cpp:34:54:   required from here
/usr/include/c++/7/bits/stl_algo.h:4882:18: error: no match for 'operator=' (operand types are 'std::back_insert_iterator<std::pair<int, int> [1000005]>' and 'std::pair<int, int>')
        *__result = *__first2;
        ~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 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 roz.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:452:11: note: candidate: constexpr std::back_insert_iterator<std::pair<int, int> [1000005]>& std::back_insert_iterator<std::pair<int, int> [1000005]>::operator=(const std::back_insert_iterator<std::pair<int, int> [1000005]>&)
     class back_insert_iterator
           ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:452:11: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::back_insert_iterator<std::pair<int, int> [1000005]>&'
/usr/include/c++/7/bits/stl_iterator.h:452:11: note: candidate: constexpr std::back_insert_iterator<std::pair<int, int> [1000005]>& std::back_insert_iterator<std::pair<int, int> [1000005]>::operator=(std::back_insert_iterator<std::pair<int, int> [1000005]>&&)
/usr/include/c++/7/bits/stl_iterator.h:452:11: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::back_insert_iterator<std::pair<int, int> [1000005]>&&'
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 roz.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:4887:18: error: no match for 'operator=' (operand types are 'std::back_insert_iterator<std::pair<int, int> [1000005]>' and 'std::pair<int, int>')
        *__result = *__first1;
        ~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 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 roz.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:452:11: note: candidate: constexpr std::back_insert_iterator<std::pair<int, int> [1000005]>& std::back_insert_iterator<std::pair<int, int> [1000005]>::operator=(const std::back_insert_iterator<std::pair<int, int> [1000005]>&)
     class back_insert_iterator
           ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:452:11: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::back_insert_iterator<std::pair<int, int> [1000005]>&'
/usr/include/c++/7/bits/stl_iterator.h:452:11: note: candidate: constexpr std::back_insert_iterator<std::pair<int, int> [1000005]>& std::back_insert_iterator<std::pair<int, int> [1000005]>::operator=(std::back_insert_iterator<std::pair<int, int> [1000005]>&&)
/usr/include/c++/7/bits/stl_iterator.h:452:11: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::back_insert_iterator<std::pair<int, int> [1000005]>&&'
roz.cpp: In function 'int main()':
roz.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
roz.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &ch);
   ~~~~~^~~~~~~~~~~~