답안 #309865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309865 2020-10-04T18:57:12 Z peuch Palindromic Partitions (CEOI17_palindromic) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1e6 + 10;

int t;
int n;
string st1;
int cnt;

map<pair<int, int>, int> marc;

int main(){
	scanf("%d", &t);
	while(t--){
		cin >> st1;
		n = st1.size();
		string aux1 = "";
		string aux2 = "";
		int ans = 0;
		cnt = 0;
		marc.clear();
		for(int i = 0; i < n / 2; i++){
			aux1 += st1[i];
			aux2 = st1[n - i - 1] + aux2;
			if(marc[aux1] == 0) marc[aux1] = ++cnt;
			if(marc[aux2] == 0) marc[aux2] = ++cnt;
			if(marc[aux1] == marc[aux2]) {
				ans += 2;
				aux1 = "";
				aux2 = "";
			}
		}
		if(n % 2 == 1) ans++;
		else if(aux1.size() != 0) ans++;
		printf("%d\n", ans);
	}
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:26:11: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   26 |    if(marc[aux1] == 0) marc[aux1] = ++cnt;
      |           ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:26:28: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   26 |    if(marc[aux1] == 0) marc[aux1] = ++cnt;
      |                            ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:27:11: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   27 |    if(marc[aux2] == 0) marc[aux2] = ++cnt;
      |           ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:27:28: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   27 |    if(marc[aux2] == 0) marc[aux2] = ++cnt;
      |                            ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:28:11: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   28 |    if(marc[aux1] == marc[aux2]) {
      |           ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:28:25: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   28 |    if(marc[aux1] == marc[aux2]) {
      |                         ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from palindromic.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const key_type&' {aka 'const std::pair<int, int>&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
palindromic.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~