This file contains hidden or 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
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAX 30000 | |
int base[MAX], diff[MAX], sum[MAX], ss[MAX]; | |
bool chk[MAX]; | |
vector<int> mp[MAX]; | |
pair<int, int> vec[MAX]; | |
int get_idx(int x) { |
This file contains hidden or 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
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAX 30000 | |
int base[MAX], diff[MAX]; | |
bool chk[MAX]; | |
pair<int, int> vec[MAX]; | |
void flip(int mat[4][4]) { | |
for (int i = 0; i < 4; i++) { |
This file contains hidden or 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
void dfs(int now, int par){ | |
cnt[now]=col[now]; | |
for(int i=0;i<adj[now].size();i++){ | |
int there=adj[now][i]; | |
if(there==par) | |
continue; | |
dfs(there, now); | |
cnt[now]+=cnt[there]; | |
} | |
dp[now][col[now]]=1; |
This file contains hidden or 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
#include <bits/stdc++.h> | |
using namespace std; | |
map<pair<int, int>, int> mp; | |
int solve(int b, int g){ | |
if(b>=40) | |
return 0; | |
if(g==1) | |
return b==0; | |
if(g<=1) | |
return 0; |
This file contains hidden or 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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int main(){ | |
int k; | |
vector<int> arr; | |
int in; | |
scanf("%d", &k); | |
while(scanf("%d", &in)!=EOF) |
This file contains hidden or 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
import java.util.concurrent.Semaphore; | |
import java.util.concurrent.ThreadLocalRandom; | |
public class Main { | |
static Philosopher philosophers[] = new Philosopher[5]; | |
static Chopsticks chopsticks[] = new Chopsticks[5]; | |
static class Chopsticks { | |
private Semaphore mutex = new Semaphore(1); |
This file contains hidden or 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
import java.util.concurrent.ThreadLocalRandom; | |
public class Main { | |
public static void main(String[] args) { | |
Philosopher[] philosophers = new Philosopher[5]; | |
PhilosopherMonitor monitor = new PhilosopherMonitor(5); | |
for (int i = 0; i 5; i++) { | |
philosophers[i] = new Philosopher(i, monitor); |
This file contains hidden or 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
#include "bits/stdc++.h" | |
using namespace std; | |
int N; | |
bool Map[2187][2187]; | |
void search(int x, int y, int k) { | |
if (k == 1) { | |
Map[x][y] = true; | |
return; | |
} | |
int t = k / 3; |
This file contains hidden or 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
//n!을 구하는 함수(반복문) | |
int fact(int n) { | |
int ret = 1; | |
for (int i = 1; i <= n; i++) | |
ret *= i; | |
return ret; | |
} | |
//n!을 구하는 함수(재귀 호출) | |
int fact_recursive(int n) { | |
//n이 0이면 더이상 쪼개지지 않는다. (기저 사례) |
NewerOlder