728x90
728x90

USACO 4

백준] 10026 - 적록색약(USACO March 2014 Bronze)

시간 제한 : 1초 메모리 제한 : 128MB 입력 첫째 줄에 N이 주어진다. (1 ≤ N ≤ 100) 둘째 줄부터 N개 줄에는 그림이 주어진다. 출력 적록색약이 아닌 사람이 봤을 때의 구역의 개수와 적록색약인 사람이 봤을 때의 구역의 수를 공백으로 구분해 출력한다. 소스코드 #include #include #include #include using namespace std; int N; int dir[4][2] = { {1,0},{-1,0},{0,1},{0,-1} }; vector arr; vector check; bool isValid(int coord) { return coord >= 0 && coord < N; } void BFS(int i, int j, int RGB) { queue q; q.p..

백준] 6160 - Election Time(USACO 2008)

시간 제한 : 1초메모리 제한 : 128MB 입력Line 1: Two space-separated integers: N and KLines 2..N+1: Line i+1 contains two space-separated integers: A_i and B_i 출력Line 1: The index of the cow that is expected to win the election. 소스코드 #include #include #include using namespace std; struct cow { int first; int second; int originIdx; }; bool compare(const struct cow &a, const struct cow &b) { return a.first > b...

백준] 1233 - 주사위(USACO 2008)

시간 제한 : 2초메모리 제한 : 128MB 입력입력 파일의 첫째 줄에 정수 S1, S2, S3가 주어진다. 출력출력 파일의 첫째 줄에 가장 높은 빈도로 나오는 세 주사위 합을 구하는 것이다. 단 답이 여러개라면 가장 합이 작은 것을 출력한다. 소스코드 #include using namespace std; int main(void) { int s1, s2, s3, arr[81] = { 0, }; cin >> s1 >> s2 >> s3; for (int i = 1; i

728x90