#24597: #0: 100% RE (SIGABRT) 系統呼叫了 abort 函式! terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)


0520ryanyu (余秉侖)

學校 : 國立科學工業園區實驗高級中學
編號 : 122637
來源 : [49.216.160.18]
最後登入時間 :
2024-10-21 14:46:13
a130. 12015 - Google is Feeling Lucky -- UVa12015 | From: [60.251.194.164] | 發表日期 : 2021-03-08 22:27

#include<bits/stdc++.h>

using namespace std;

struct NODE{

string name;

int times, num;

bool good;

};

 

bool compare(NODE a, NODE b){

return a.times > b.times;

}

bool comp(NODE a, NODE b){

return a.num < b.num;

}

int main(){

int n;

cin>>n;

int Case = 1;

while(n-->0){

NODE arr[10];

for(int i = 0; i < 10; i++){

cin>>arr[i].name>>arr[i].times;

arr[i].num = i;

bool good = 0;

}

sort(arr, arr+10, compare);

 

int big;

for(int i = 0; i < 10; i++){

if(i == 0){

big = arr[i].times;

}else{

if(big != arr[i].times){

big = i;

break;

}

}

}

NODE great[big];

for(int i= 0; i < big;i++){

great[i].name = arr[i].name;

great[i].num = arr[i].num;

great[i].times = arr[i].times;

}

sort(great, great+big, comp);

cout << "Case #"<<Case<<':'<<'\n';

for(int i = 0; i < big; i++){

cout << great[i].name << '\n';

}

Case++;

 

}

}

 

寫了很久為何會RE?

 

 
ZeroJudge Forum