제출 #397087

#제출 시각아이디문제언어결과실행 시간메모리
397087abdzagLottery (CEOI18_lot)C++17
0 / 100
733 ms552 KiB
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b); i--); #define all(v) v.begin(),v.end() #define trav(a,v) for(auto&a:v) using namespace std; const long long inf = 1e15; typedef long long ll; int main() { cin.sync_with_stdio(false); ll n,l; cin >> n >> l; vector<ll> s(n); rep(i, 0, n)cin >> s[i]; ll q; cin >> q; ll i = 1, j = 0; vector<ll> p(s.size()); while (i < s.size()) { if (s[i] == s[j]) { j++; p[i] = j; i++; } else { while (j) { if (s[j - 1] == s[i])break; j = p[j - 1]; } p[i] = j; i++; } } rep(Q, 0, q) { vector<ll> res(n-l+1,-1); ll k; cin >> k; rep(start, 0, n - l + 1) { i = 0; j = 0; ll cur = 0; while (i < s.size()) { if (j < l && (s[i] == s[start + j])) { if (s[i] != s[start + j])cur++; i++; j++; } else { cur--; while (j) { if (s[start + j - 1] == s[i])break; j = p[j - 1]; } i++; } if (j == l) { res[start]++; } } } trav(a, res)cout << a << " "; cout << endl; } return 0; }

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

lot.cpp: In function 'int main()':
lot.cpp:23:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  while (i < s.size()) {
      |         ~~^~~~~~~~~~
lot.cpp:46:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    while (i < s.size()) {
      |           ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...