• 카테고리

    질문 & 답변
  • 세부 분야

    알고리즘 · 자료구조

  • 해결 여부

    미해결

맞왜틀

22.04.25 20:08 작성 조회수 147

0

빨간 세로선 기준으로 왼쪽이 제가 입력한 코드의 결과이고 오른쪽이 강사님의 코드의 결과입니다.

채점을 할 때 강사님꺼는 Success가 뜨는데 제꺼는 Wrong_answer가 뜨네요 ㅠ 뭐가 문제일까요.

 

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <string>

#include <algorithm>

#include <vector>

#include <stack>

 

using namespace std;

 

int main(int argc, char** argv) {

//freopen("input.txt", "rt", stdin);

int n, i = 1, j = 0, start, count = 0;

scanf("%d", &n);

stack<int> s;

char* a = new char[n * 2];

 

while (count < n) {

scanf("%d", &start);

s.push(start);

a[j++] = 'P';

 

while (!s.empty() && s.top() == i) {

s.pop();

a[j++] = 'O';

i++;

}

 

count++;

}

 

if (s.empty()) {

for (i = 0; i < j; i++)

printf("%c", a[i]);

}

else

printf("impossible\n");

delete[] a;

}

 

답변 1

답변을 작성해보세요.

0

물쉬드님의 프로필

물쉬드

질문자

2022.04.25

시간지나서 빌드하고 다시해보니 제대로 채점되네요! 뭔가 이상한 프로그램 오류가 있었나봅니다!