Submission #674658

# Submission time Handle Problem Language Result Execution time Memory
674658 2022-12-25T16:23:46 Z vjudge1 Kamenčići (COCI21_kamencici) C++17
0 / 70
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
 
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define ppb pop_back
#define read(a) for(auto &x:a) cin >> x;
#define print(a) for(auto x:a) cout << x << " "; cout << "\n";
#define vc vector<char>
#define vvc vector<vc>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define int long long
#define ld long double
const int INF = 4e18;

void solve(){
    int n, k; cin >> n >> k;
    string s; cin >> s;

    int a = 0, b = 0, l = 0, r = n-1, t = 0;
    while(l <= r){
        if(a == k){
            cout << "NE\n";
            return;
        }
        if(b == k){
            cout << "DA\n";
            return;
        }

        if(s[l] == 'P'){
            l++; t = 1-t;
            continue;
        }
        if(s[r] == 'P'){
            r--; t = 1-t;
            continue;
        }

        int dl = 0, dr = 0, ix;
        ix = l;
        while(s[ix] == 'C') dl++, ix++;
        ix = r;
        while(s[ix] == 'C') dr++, ix--;

        if(dl > dr){
            l++;
            if(t == 0) a++;
            else b++;
            t = 1-t;
            continue;
        } else {
            r--;
            if(t == 0) a++;
            else b++;
            t = 1-t;
            continue;
        }
    }
    if(a == k){
        cout << "NE\n";
        return;
    }
    if(b == k){
        cout << "DA\n";
        return;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif

    int tt = 1;
    // cin >> tt;
    while(tt--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -