#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int visited[105]; int t[105][105]; int from[105]; int n, end_sub; struct QData { int now; int time; }; struct QDataC { bool operator()(const QData &a, const QD..
#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; template struct MAX_HEAP { vector heap; MAX_HEAP(){ heap.push_back(-1); } void add(T x) { heap.push_back(x); int c = heap.size() - 1; while(c > 1 && heap[c / 2] < heap[c]) { swap(h..
#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1, 0}; int dy[] = {1, -1, 0, 0, 1, 1, -1, -1, 0}; int n; // size of board bool board[30][30]; // 어ㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓㅓ 왔다 갔다 하는거 어케하누;; bool visited[30][30][30][30]; struct Pos { int x; int y; }..
#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pi_i; const int MAXN = 100000, MAXM = 500000; vector paths[MAXN + 5]; bool visited[MAXN + 5]; void dfs(int now){ cout n >> m; for(int i = 0;i > from >> to; paths[from].push_back(to); paths[to].push_back(from); } for(int i = 1;i
#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; typedef signed char i8; typedef short i16; typedef int i32; typedef long long i64; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int m = 0; int r = 0; int rs[110]; int rt[110]; int memo[110]; int path[110]..
#include using namespace std; typedef long long ll; typedef pair pii; int ans = 0 , n;; // board[y] = x // y번째 줄에는 x번째 칸에 queen이 있다 int board[15]; bool ok(int step){ for(int i = 0;i < step;i++){ if(board[i] == board[step]) return false; // 위 아래 if(step - i == abs(board[step] - board[i])) return false; // 대각선 } return true; } void st(int step){ if(step == n){ ans++; return; } for(int i = 0;i < n;..
#include int main(){ int n , m; scanf("%d %d" , &n , &m); for(int i = 0;i < n;i++){ if(i % 2 == 0){ for(int j = 1;j = 1;j--){ printf("%d " , i * m + j); } } printf("\n"); } }
#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; // games[Country][Win | Same | Lose] int games[10][5]; int result_games[10][5]; int team1[] = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4 }; int team2[] = { 1, 2, 3, 4,..
#include using namespace std; typedef pair pii; int n, m; int board[100][100]; bool visited[100][100]; bool air[100][100]; int dy[4] = { -1, 0, 1, 0 }; int dx[4] = { 0, 1, 0, -1 }; int main() { int cnt = 0; int ans = 0; cin >> n >> m; for (int i = 0; i > board[i][j]; visited[i][j] = false; air[i][j] = true; if (board[i][j] == 1) cnt++; } } int hour ..