結果
| 問題 |
No.2204 Palindrome Splitting (No Rearrangement ver.)
|
| コンテスト | |
| ユーザー |
鴨志田卓
|
| 提出日時 | 2023-07-21 01:08:06 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 522 bytes |
| コンパイル時間 | 7,628 ms |
| コンパイル使用メモリ | 244,436 KB |
| 最終ジャッジ日時 | 2025-02-15 16:00:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:19:9: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'char*')
19 | cin >> (s + 1);
| ~~~ ^~ ~~~~~~~
| | |
| | char*
| std::istream {aka std::basic_istream<char>}
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
168 | operator>>(bool& __n)
| ^~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/istream:168:7: note: conversion of argument 1 would be ill-formed:
main.cpp:19:15: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'char*'
19 | cin >> (s + 1);
| ~~~^~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
172 | operator>>(short& __n);
| ^~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/istream:172:7: note: conversion of argument 1 would be ill-formed:
main.cpp:19:15: error: invalid conversion from 'char*' to 'short int' [-fpermissive]
19 | cin >
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
char s[N];
int n;
int ok[N][N], dp[N];
bool p(int l, int r) {
if(r - l < 1) return true;
if(!ok[l][r])
ok[l][r] = p(l + 1, r - 1) && s[l] == s[r] ? 1 : -1;
return ok[l][r] > 0;
}
int main() {
cin >> (s + 1);
n = strlen(s + 1);
dp[0] = N;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= i; j ++) {
if(p(j, i)) dp[i] = max(dp[i], min(dp[j - 1], i - j + 1));
}
}
cout << dp[n];
}
鴨志田卓