제출 #397089

#제출 시각아이디문제언어결과실행 시간메모리
397089abdzagLottery (CEOI18_lot)C++17
0 / 100
786 ms536 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; } 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 (s[i] == s[start + j]) { if (s[i] != s[start + j])cur++; i++; j++; } if (j == l) { res[start]++; j = p[j - 1]; } else if (i < s.size() && s[start + j] != s[i]) { cur--; if (j)j = p[j - 1]; else i++; } } } 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:45: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]
   45 |    while (i < s.size()) {
      |           ~~^~~~~~~~~~
lot.cpp:55:16: 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]
   55 |     else if (i < s.size() && s[start + j] != s[i]) {
      |              ~~^~~~~~~~~~
#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...