제출 #1157289

#제출 시각아이디문제언어결과실행 시간메모리
1157289SmuggingSpunPalindromic Partitions (CEOI17_palindromic)C++20
100 / 100
91 ms11024 KiB
#include<bits/stdc++.h> #define taskname "B" using namespace std; typedef long long ll; const int mod = 2e9 + 33; const int base = 397; const int lim = 1e6 + 5; int hash_value[lim], pw_base[lim]; int get(int l, int r){ return (ll(hash_value[r]) - 1LL * hash_value[l - 1] * pw_base[r - l + 1] + 1LL * mod * mod) % mod; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } for(int i = pw_base[0] = 1; i < lim; i++){ pw_base[i] = 1LL * pw_base[i - 1] * base % mod; } int _t; cin >> _t; for(int _ = hash_value[0] = 0; _ < _t; _++){ string s; cin >> s; int n = s.size(), ans = 0; for(int i = 1; i <= n; i++){ hash_value[i] = (1LL * hash_value[i - 1] * base + s[i - 1]) % mod; } for(int i = 1; i <= ((n + 1) >> 1); i++){ bool have = false; for(int j = i; j <= (n >> 1); j++){ if(get(i, j) == get(n - j + 1, n - i + 1)){ have = true; i = j; ans += 2; break; } } if(!have){ ans++; break; } } cout << ans << "\n"; } }

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

palindromic.cpp: In function 'int main()':
palindromic.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...