Created
December 19, 2011 14:42
-
-
Save pogin503/1497501 to your computer and use it in GitHub Desktop.
TopCoder SRM 152 DIV2 500pt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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