목록C++언어 (27)
레야몬
#include #define MAX_N 1001 using namespace std; int Max[MAX_N]; //가장 긴 부분 수열의 길이 (메모리제이션) int map[MAX_N]; //수열 int N; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N; for(int i=1; i> map[i]; for(int i=1; i
#include #define MAX_N 16 using namespace std; int N; //체스판의 크기 int cnt; //가능한 경우의 수 int map[MAX_N]; bool posi(int col) //col에 퀸을 놓을 수 있는가? { for(int i=1; i N; f(1); cout
#include #include #include #define MAX_NUM 100002 using namespace std; int T, n; //테스트 케이스의 개수 T, 스티커 가로 크기 n int map[3][MAX_NUM]; //스티커 맵 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> T; for(int i=0; i> n; for(int j=0; j map[j][k]; } for(int i=1; i
#include #include #include using namespace std; typedef long long ll; __uint128_t memo[101][101]; __uint128_t comb(int n, int r) { if(n> n >> r; res = comb(n, r); string a = ""; string f = to_string((ll) (res / (__uint128_t)pow(10, 15))); string s = to_string((ll) (res % (__uint128_t)pow(10, 15))); if(f=="0") a=s; else a=f+s; cout int 로 변.. blockdmask.tistory.com ※현재 고등학교 등교중인 학생입니다. 이제 알고리즘을 본격..
#include #define MAX_VERTEX 100001 using namespace std; int Index[MAX_VERTEX]; int io[MAX_VERTEX], po[MAX_VERTEX]; int n; void f(int io_left, int io_right, int po_left, int po_right) { if(io_left > io_right) return; int rootIndex = Index[po[po_right]]; int ls = rootIndex - io_left; cout po[i]; f(1, n, 1, n); return 0; } ㅈㄹ 어렵다.. 나에겐 아직 골드2는 버거운건가 참고한 사이트는 아래에 있다. 오랫만에 주석을 안적었는데.ㅠㅠ https://salgur..
#include #include #define MAX_MAP_SIZE 1002 #define IOF 987654321 using namespace std; typedef struct _loc { int x; int y; int nb_cnt; //부수다: break, 부수지 않다: not break int b_cnt; } loc; int Dist[MAX_MAP_SIZE][MAX_MAP_SIZE][2]; //거리의 최솟값(안 부쉈나? 부쉈나?) char Map[MAX_MAP_SIZE][MAX_MAP_SIZE]; //맵 queue q; //bfs용 큐 int N, M; //맵의 크기 int X_d[4] = {1, 0, -1, 0}; //X direction int Y_d[4] = {0, -1, 0, 1}; i..
#include #define MAX_VERTEX 'Z'+1 using namespace std; pair tr[MAX_VERTEX]; //이진 트리 int N; //이진 트리의 노드의 개수 void f(char Node) { cout > b; tr[u] = {v, b}; //왼쪽 노드, 오른쪽 노드 } f('A'); cout
#include #include #include #define Max_Vertex 10010 using namespace std; int Dist[Max_Vertex]; //최대 가중치 vector Tr[Max_Vertex]; //두 정점과, 가중치. 간선: truck int visit[Max_Vertex]; int n; //노드의 개수 int m, p; //최대 가중치의 합과, 루트에서 최대 가중치의 위치 void f(int Node, int cnt) //탐색할 노드와, 지금까지 더해진 가중치의 합 { visit[Node]=1; for(int i=0; i n; for(int i=0; cin >> u >> v >> w; i++) { Tr[u].push_back({v, w}); //튜플 형태로 저장하기 T..