sky456139   6년 전

테스트 케이스도 작성해봤는데 어디서 런타임 에러가 나는걸까요? ㅜㅜ


'''

#include<iostream>
#include<list>

using namespace std;

int main() {
int n;
int next;
cin >> n; 
list<pair<int, int>> balloon; 
for (int i = 0; i < n; i++) { 
int m;
cin >> m; 
balloon.push_back(make_pair(m, i + 1)); 
}
while (balloon.size() != 0) {
if (balloon.size() == n) { 
cout << balloon.front().second << ' '; 
next = balloon.front().first; 
balloon.pop_front();
}
if (balloon.size() == 1) {
cout << balloon.front().second << ' ';
balloon.pop_front();
break;
}
if (next > 0) { 
auto it = balloon.begin(); 
for (int i = 1; i < next; i++)  
it++;
cout << it->second << ' ';
next = it->first; 
balloon.erase(it);
}
else if (next < 0) {
auto it = --balloon.end();
for (int i = next; i < 0; i++) {
if (it == balloon.begin() || balloon.size() == 2) {
it = --balloon.end();
continue;
}
--it;
}
cout << it->second << ' ';
next = it->first;
balloon.erase(it);
}
}
return 0;
}


'''

sgchoi5   6년 전

문제화면에서 질문하기를 선택하시면 문제 번호가 자동으로 들어가서 확인하기가 편합니다. 지금은 그냥 질문하기로 하셔서 어떤 문제인지 찾기가 어렵습니다.

댓글을 작성하려면 로그인해야 합니다.