Submission #1023759

#TimeUsernameProblemLanguageResultExecution timeMemory
1023759vjudge1JJOOII 2 (JOI20_ho_t2)C++17
1 / 100
580 ms436 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("Ofast") #define pii pair <int, int> #define pb push_back #define pp pop_back #define int int64_t #define sc second #define fr first using namespace std; const int T=1e9+7; signed main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); int n, k, i, j, a, J, O, I, t, mn=T, x, y; string s; bool r, q; cin >> n >> k >> s; a=(1<<n); for (j=1; j<a; j++) { r=1, q=1, x=0, y=0; bitset <2024> b(j); vector <char> v; for (i=0; i<min(a, n); i++) { if (b[i]==1) { v.pb(s[i]); if (q) x=i, q=0; else y=i; } } if (int(v.size())!=k*3) continue; for (i=0; i<k; i++) { if (v[i]!='J') { r=0; break; } } for (i=k; i<2*k; i++) { if (v[i]!='O') { r=0; break; } } for (i=2*k; i<3*k; i++) { if (v[i]!='I') { r=0; break; } } // for (auto j: v) { // cout << j; // } // cout << '\n'; // cout << x << ' ' << y << '\n'; if (r) mn=min(y-x-k*3+1, mn); } if (mn==T) cout << -1; else cout << mn; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:17:21: warning: unused variable 'J' [-Wunused-variable]
   17 |  int n, k, i, j, a, J, O, I, t, mn=T, x, y;
      |                     ^
ho_t2.cpp:17:24: warning: unused variable 'O' [-Wunused-variable]
   17 |  int n, k, i, j, a, J, O, I, t, mn=T, x, y;
      |                        ^
ho_t2.cpp:17:27: warning: unused variable 'I' [-Wunused-variable]
   17 |  int n, k, i, j, a, J, O, I, t, mn=T, x, y;
      |                           ^
ho_t2.cpp:17:30: warning: unused variable 't' [-Wunused-variable]
   17 |  int n, k, i, j, a, J, O, I, t, mn=T, x, y;
      |                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...