본문 바로가기

code/SWEA

(10)
19' 하반기 10월 20일 삼성전자 SW 역량 테스트 후기 9월 상시 역테에 이어 다시 인재개발원에서 시험을 보게되었다. 같은 시험장이지만 분위기는 사뭇 달랐다. 시험 감독관으로 훨씬 더 많은 분들이 나와 계셨고 정식 입사시험이라 그런지 비장한 분위기가 느껴졌다. 모든 것이 9월에 비해 훨씬 체계적으로 돌아갔다. 엘레베이터를 타는 것도 직원 분들의 안내와 감독을 받았고, 안내 받은 시작 시간이 됐는데도 교실에 들어가지 못 했던 9월과 비교하면 시험 진행 과정 역시 모두 체계적이었다. 지난 번 시험을 봤던 교실과 같아서(...) 긴장하지 않고 볼 수 있었던 것 같다. 결과는 1 문제를 풀었다. 맞았으면 좋겠다. 시험을 끝내고 인개원을 나서는데 너무나 익숙한 풍경이어서 직감을 믿고 카톡을 하면서 걸어가다가 결국에는 이상한 길로 접어들어 한참을 돌아가야했다. 최단거리..
줄기세포 #include #include #define f(i, n) for(int i = 0 ; i < (n); ++i) using namespace std; int T, tc, R, C, K; int lf[2][650][650], rm[2][650][650], st[2][650][650];// 초기화완료 bool sd; // dfs1 int vst1[650][650], v; int dr[] = { -1, 0, 1, 0 }; int dc[] = { 0, 1, 0, -1 }; int rb, cb;// 초기화 완료 void dfs1(int r, int c) { vst1[r][c] = v; rm[!sd][r][c] = rm[sd][r][c] - 1;// 수명 감소 if (rm[sd][r][c] == 0 && st[s..
SWEA 제주도 여행 #include #include #define f(i, n) for(int i = 0; i < (n); ++i) using namespace std; int T, N, M; int adj[35][35]; struct info { char tp; int tm, st; }; info atr[35]; int ap;// 공항 int ht[35], hts;// 초기화 완료 // dfs int rt[35]; int msts, mrt[35], mrts;// 초기화 완료 bool vst[35]; // tc void bf(int s, int hr, int dy, int sts) { bool go_ht = false; bool go_ap = false; for (int u = 0; u < N; ++u) { if (vst[..
SWEA 1824 혁진이의 프로그램 인증 설계: 결국에는 src에서 dst로 갈 수 있는지 dfs(vst 추가 차원 필요) 코드: 처음에는 visited를 좌표, 메모리 기준으로만 처리했으나 3개의 TC가 통과되지 않아 방향을 추가하여 AC #include #define f(i, n) for(int i = 0; i < (n); ++i) using namespace std; int R, C; char prg[20][20]; int vst[20][20][18][4], v; int rot[4], rots; int dr[] = { -1, 0, 1, 0 }; int dc[] = { 0, 1, 0, -1 }; int ad[16], sb[16]; void edge(int &r, int &c) { if (r == -1) r = R - 1; else if (r..
SWEA 5648 원자 소멸 시뮬레이션 1. 다른 문제와 달리 좌표평면 상의 좌표가 주어진다. 좌표가 가로위치 -> 세로위치 순으로 주어지며, 오른쪽 아래 방향이 가로위치와 세로위치가 증가하는 방향이다. 2. while(1)의 탈출조건인 ctr T; for (int tc = 1; tc > N; for(int a = 0; a > x >> y >> d >> k; atoms[a] = { 2 * (x + 1000), 2 * (y + 1000), d, k }; } int ans = 0; while (1) { c = 1; ctr = 0; for (int a = 0; a < N; ++a) { if (atoms[a].x == -1) continue; atoms[a].x += dx[atoms[a].d..
SWEA 2383 점심 식사시간 코드: /* 1. 바로 다음(next(it))이 아니라 this trhead보다 큰 tm 필드를 지니는 thread 선택해야 */ #include #include #include #include using namespace std; vector hm; vector ext; vector extn; bool cbn[10]; int ans; struct thrd { int tm; bool job; int hmn; bool wait; }; struct oprt { bool operator()(const thrd &a, const thrd &b) const { if (a.tm == b.tm) { if (a.job == b.job) { return a.hmn b.job..
SWEA 1949 등산로 조성 코드: /* 1. visited 값을 v로 설정했으면 not visited는 !vst[nr][nc]가 아니라 vst[nr][nc] != v */ /* 2. 깎는 건 한 번만 */ /* 3. 전역 변수 초기화 */ /* 4. 깎는 횟수만큼 재방문 가능해야 하므로 재방문 허용 */ #include #include #include using namespace std; int T; int N, K; int map[8][8]; bool vst[8][8]; int ans; const int dr[] = { -1, 0, 1, 0 }; const int dc[] = { 0, 1, 0, -1 }; #define IN(r, c) (0 > T; for (int t = 1; t > N >> K; int pkh = 0; vec..
SWEA 2117 홈 방범 서비스 코드: /* 1. 좌표 행열 상한 모두 N */ /* 2. 전역변수 초기화 */ /* 3. 안 돌아가는 TC 파악하기 같은 특성의 작은 TC 만들어서 해보는 것도 중요 */ /* 4. 정답 판별 중간에만 하지 말고 끝에도 해줄 것 */ #include #include using namespace std; int T; int N, M; bool map[20][20]; int vst[20][20]; int v = 1; int ans; int dn[] = { -1, 0, 1, 0 }; int dm[] = { 0, 1, 0, -1 }; #define IN(n, m) (0 > T; for (int t = 1; t > N >> M; for (int n = 0; n < N; ++n) { for (int m = 0; ..