제출 #1369750

#제출 시각아이디문제언어결과실행 시간메모리
1369750AliMark71Tornjevi (COCI25_tornjevi)C++20
61 / 110
1094 ms5096 KiB
//
//  main.cpp
//  IntensiveCamp 1 2026
//
//  Created by Ali AlSalman on 27/04/2026.
//
 
#include <bits/stdc++.h>


//#define INTERACTIVE
//#define TESTCASES
//#define FUNCTIONAL
//#define SPOJ_BULLSCHEI__SZ__E__KIJETESANPAKALU__
 
#ifndef INTERACTIVE
#define endl '\n'
#endif
 
template<typename T>
using vec = std::vector<T>;
using namespace std;

void solve() {
    int n, q;
    string s;
    cin>>n>>q>>s;
    vec<bool> color(n);
    set<int> ind[2];
    
    while (q--) {
        int l, r;
        cin>>l>>r; l--; r--;
        
        for (int i = 0; i < n; i++)
            ind[color[i] = s[i] == 'P'].insert(i);
        ind[0].insert(n);
        ind[1].insert(n);
        
        vec<bool> vis(n);
        int ans = 0;
        for (int i = l; i <= r; i++) if (!vis[i]) {
            ans++;
            int n = i;
            while (n <= r) {
                vis[n] = true;
                ind[color[n]].erase(n);
                auto &other_color = ind[!color[n]];
                n = *other_color.upper_bound(n);
            }
            
        }
        
        cout<<ans<<endl;
    }
    
}
 
#ifndef FUNCTIONAL
int main() {
#ifndef INTERACTIVE
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif
    
    int t = 1;
#ifdef TESTCASES
    cin>>t;
#endif
    
    for (int i = t; i--;) {
#if defined(TESTCASES) && defined(SPOJ_BULLSCHEI__SZ__E__KIJETESANPAKALU__)
        cout<<"Case "<<t-i<<":\n";
#elif defined(SPOJ_BULLSCHEI__SZ__E__KIJETESANPAKALU__)
#warning SPOJ_BULLSCHEIßE__KIJETESANPAKALU__ without TESTCASES doesn't ducking make sense!
#endif
        solve();
    }
    return 0;
}
#endif

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

Main.cpp:74:69: warning: missing terminating ' character
   74 | #warning SPOJ_BULLSCHEIßE__KIJETESANPAKALU__ without TESTCASES doesn't ducking make sense!
      |                                                                     ^
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…