제출 #150048

#제출 시각아이디문제언어결과실행 시간메모리
150048코딩은 체육과목입니다 (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
17 ms4344 KiB
#include "bulb.h" #include <stdio.h> #include <vector> #include <queue> #include <algorithm> #include <iostream> #include <string> #include <bitset> #include <map> #include <set> #include <tuple> #include <string.h> #include <math.h> #include <random> #include <functional> #include <assert.h> #include <math.h> #define all(x) (x).begin(), (x).end() #define xx first #define yy second using namespace std; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; int parent[300005]; int sel[1005][1005]; bool visit[1005]; int FindWinner(int T, std::vector<int> L, std::vector<int> R){ int N = L.size(); for (int i = 0; i < N; i++) { if (L[i] >= 0) parent[L[i]] = i; if (R[i] >= 0) parent[R[i]] = i; } // �� ó�� �� int first = 0; while (first >= 0) first = L[first]; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) sel[i][j] = first; for (int i = 0; i < N; i++) { memset(visit, false, sizeof(visit)); if (L[i] < 0) { vector<int> rs; int now = i; visit[i] = true; while (now != parent[now]) { if (now == R[parent[now]]) rs.push_back(parent[now]); now = parent[now]; visit[now] = true; } if (rs.size() == 2) { sel[rs[0]][rs[1]] = L[i]; sel[rs[1]][rs[0]] = L[i]; } if (rs.size() == 1) { for (int j = 0; j < N; j++) if (!visit[j]) sel[rs[0]][j] = sel[j][rs[0]] = L[i]; } } if (R[i] < 0) { vector<int> rs; rs.push_back(i); int now = i; visit[i] = true; while (now != parent[now]) { if (now == R[parent[now]]) rs.push_back(parent[now]); now = parent[now]; visit[now] = true; } if (rs.size() == 2) { sel[rs[0]][rs[1]] = R[i]; sel[rs[1]][rs[0]] = R[i]; } if (rs.size() == 1) { for (int j = 0; j < N; j++) if (!visit[j]) sel[rs[0]][j] = sel[j][rs[0]] = L[i]; } } } int winner = 0; for (int f = 0; f < N; f++) { //��� �ι�° ���ÿ� ���� �� R�� ������ �¸� ���� bool allRed = true; for (int s = 0; s < N; s++) { if (sel[f][s] == -2) allRed = false; } if (allRed) winner = 1; } return winner; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...