Submission #156109

#TimeUsernameProblemLanguageResultExecution timeMemory
156109karmaJOIOJI (JOI14_joioji)C++14
100 / 100
45 ms6216 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FileName "test" #define ll long long #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ord_set; typedef pair<int, int> pii; const int N = int(1e3) + 2; int n, curi, curj, curo, res = 0; pii cur; string s; map<pii, int> mmap; void Enter() { cin >> n >> s; curi = curj = curo = 0; cur = mp(0, 0); mmap[cur] = -1; for(int i = 0; i < n; ++i) { if(s[i] == 'O') ++curo; else if(s[i] == 'J') ++curj; else ++curi; cur = mp(curo - curi, curj - curo); if(mmap.count(cur)) { res = max(res, i - mmap[cur]); //cout << mmap[cur] << ' ' << i << '\n'; } else mmap[cur] = i; } cout << res; } void Solve() { } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(FileName".inp", "r")) { freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); } Enter(), Solve(); return 0; }

Compilation message (stderr)

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