답안 #499502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499502 2021-12-28T14:10:17 Z Alisaf9 Kamenčići (COCI21_kamencici) C++14
0 / 70
193 ms 524292 KB
#include <bits/stdc++.h>
 
using namespace std;




int main()
{
    string s;
    int n,k,first=0,second=0,i=0;
bool w[n];
    cin>>n>>k;
cin>>s;
int q=s.size()-1;
    while (i<q)
    {
          if (s[i]=='P')
        {
            w[i]=1;
            i++;
        }
        else if (s[q]=='P')
        {
            w[q]=1;
            q--;
        }
        else if (s[i]=='C'&&s[i+1]=='C')
        {
            first++;
            w[i]=1;
            i++;
        }
        else if (s[q]=='C' && s[q-1]=='C')
        {
            
            first++;
            w[q]=1;
            q--;
        }
        else if (s[i]=='C')
        {
            
            first++;
            w[i]=1;
            i++;
        }
        if (first>=k)
            break;
        if (s[i]=='P')
        {
            w[i]=1;
            i++;
        }
        else if (s[q]=='P')
        {
            w[q]=1;
            q--;
        }
        else if (s[i]=='C' && s[i+1]=='C')
        {
            w[i]=1;
            second++;
            i++;
        }
        else if (s[q]=='C' && s[q-1]=='C')
        {
            w[q]=1;
            second++;
            q--;
        }
        else if (s[i]=='C')
        {
            w[i]=1;
            second++;
            i++;
        }
        if (second>=k)
            break;
    }
    if (second>first)
    {
        cout<<"DA";
    }
    else
        cout<<"NE";
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:6: warning: variable 'w' set but not used [-Wunused-but-set-variable]
   12 | bool w[n];
      |      ^
Main.cpp:12:9: warning: 'n' is used uninitialized in this function [-Wuninitialized]
   12 | bool w[n];
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 193 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 193 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 193 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -