Skip to content

Instantly share code, notes, and snippets.

@pogin503
Created December 19, 2011 14:42
Show Gist options
  • Save pogin503/1497501 to your computer and use it in GitHub Desktop.
Save pogin503/1497501 to your computer and use it in GitHub Desktop.
TopCoder SRM 152 DIV2 500pt
#line 5 "LeaguePicks.cpp"
#include <vector>
using namespace std;
class LeaguePicks {
public:
vector <int> returnPicks(int position, int friends, int picks) {
vector<int> array;
for(int i = 1; i <= friends; ++i){
array.push_back(i);
}
int count = 1;
vector <int> result;
while(picks >= count){
vector<int>::iterator it;
for( it = array.begin(); it != array.end(); it++){
if(count > picks){
goto end;
}
if(*it == position){
result.push_back(count);
}
count++;
}
reverse(array.begin(), array.end());
for(it = array.begin(); it != array.end(); it++){
if(count > picks){
goto end;
}
if(*it == position){
result.push_back(count);
}
count++;
}
it = array.begin();
reverse(array.begin(), array.end());
}
end:
return result;
}
};
int main(){
LeaguePicks test;
test.returnPicks(3,6,15);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment