mkagenius's blog

By mkagenius, 11 years ago, In English

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]
Tags srm
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    11 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Right, now it ran, so the issue must be resolved now, are you still facing the same?

    • »
      »
      »
      11 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      No, it actually never happened to me, but I read of many contestants complaining about it yesterday and earlier today.