Блог пользователя mkagenius

Автор mkagenius, 13 лет назад, По-английски

When I run "Run systest", it gives me segmentation fault. When I try the same test case in the applet's editor, it gives correct result.

Weird Compiler!



class TeamContest { public: int worstRank(vector <int> strength) { if((int)strength.size() == 3) { return 1; } vector<int> remaining; for(int i = 3; i < strength.size(); i++){ remaining.push_back(strength[i]); } sort(remaining.begin(), remaining.end()); int mn = min(strength[0], min(strength[1], strength[2])); int mx = max(strength[0], max(strength[1], strength[2])); int sum = mn + mx; int end = (int)remaining.size() - 1; int required = sum + 1 - remaining[end]; // cerr << required << endl; for(int i = 0; i < remaining.size(); i++){ cout << remaining[i] << " "; } // cerr << "-----------------------\n"; int ind = 0; int cnt = 0; while(((ind < end &mdash; 1))){ while((ind < end &mdash; 1) && (required > remaining[ind])){ ind++; } if(ind >= end -1) break; // cerr << "[" << ind << "," << end << "]" << endl; ind+=2; end--; cnt++; if(end >= 0 && end < remaining.size()) required = sum+1-remaining[end]; } return 1 + cnt; } }; [/code]
Теги srm
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Looks like its a general problem — http://mirror.codeforces.com/blog/entry/7014

»
13 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I just tested your code and it ran OK, but I've heard of many people having the same problem as yours. I think it's a system issue.