제출 #753888

#제출 시각아이디문제언어결과실행 시간메모리
753888vjudge1JJOOII 2 (JOI20_ho_t2)C++17
0 / 100
0 ms212 KiB
//time 06.06.2023 23:00 #include <bits/stdc++.h> #define ll long long #define s second #define f first using namespace std; const ll N = 2e5+ 9; const ll inf = 1e18; const ll b_N = 2e5 + 9; char a[N]; void solve(){ int n,k; cin >> n >> k; int q = 0,w = 0,e = 0; for(int i = 1;i <= n;i++){ cin >> a[i]; if(a[i] == 'J' && q < k)q++; else if(q >= k && a[i] == 'O' && w < k)w++; else if(q >= k && a[i] == 'I' && e < k && w >= k)e++; } if(q < k || w < k || e < k)cout << -1; else if(q == k && w == k && e == k && n % k == 0 && n / k == 3)cout << 0; else{ int sum = n - (3 * k); if(a[1] == 'J' && a[n] == 'I'); else if(a[1] == 'J' && a[n] != 'O')sum--; else if(a[1] != 'J' && a[n] == 'O')sum--; else sum -= 2; cout << sum; } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("herding.in","r",stdin); // freopen("herding.out","w",stdout); solve(); }

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

ho_t2.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...