제출 #885123

#제출 시각아이디문제언어결과실행 시간메모리
885123catlover새로운 문제 (POI11_roz)C++14
80 / 100
588 ms36876 KiB
#include <bits/stdc++.h> #define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; --i) #define pb push_back #define SZ(X) (int)((X).size()) using namespace std; const int maxN = 1e6; int N; string s; vector<int> id[maxN+5]; void read_input() { cin >> N >> s; } void solve() { s = ' ' + s; FOR(i, 1, N) id[s[i] - 'a'].pb(i); int res = 0; FOR(x, 0, 25) { FOR(y, 0, 25) { if(SZ(id[x]) * SZ(id[y]) == 0) continue; if(x == y) continue; vector<int> d {0}; int j = 0; for(int i : id[x]) { while(j < SZ(id[y]) && id[y][j] < i) { ++j; d.pb(-1); } d.pb(1); } while(j < SZ(id[y])) { ++j; d.pb(-1); } int last = 0, mn = 1e9; vector<int> f(SZ(d), 0); FOR(i, 1, SZ(d) - 1) { f[i] = f[i - 1] + d[i]; if(i > 1 && d[i] != d[i - 1]) { FOR(j, last, i - 2) mn = min(mn, f[j]); last = i - 1; } res = max(res, f[i] - mn); } } } cout << res; } int main() { cin.tie(0)->sync_with_stdio(0); file("SSDIFF"); read_input(); solve(); return 0; }

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

roz.cpp: In function 'int main()':
roz.cpp:3:56: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
roz.cpp:71:3: note: in expansion of macro 'file'
   71 |   file("SSDIFF");
      |   ^~~~
roz.cpp:3:89: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define file(task) if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
roz.cpp:71:3: note: in expansion of macro 'file'
   71 |   file("SSDIFF");
      |   ^~~~
#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...
#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...