코딩테스트/백준
[실5] 30457 - 단체줄넘기
#include #include #include #include using namespace std;using IntPair = pair;#define y first#define x second#define MAX 1000// 다음 위치 시계 방향IntPair pos[]{ { 1, 0 }, // 북 { 0, 1 }, // 서 {-1, 0 }, // 남 { 0,-1 } // 동};int main(){ int n, res = 0; cin >> n; vector cnt(MAX + 1); for (int i = 0; i > n; cnt[n]++; } for (int i = 0; i
[실3] 24725 - 엠비티아이
#include #include #include #include #include #include #include using namespace std;using IntPair = pair;using ll = long long;IntPair dir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우 {1, -1}, {1, 1}, {-1, -1}, {-1, 1 },};#define MAX 2string alpha[]{"E","I", "N", "S", "F", "T", "P", "J"};vector mbti, board;int n, m, res;void Init(){ // E N F P > [0][0] + [1][0] + [2][0] + [3][..
[실2] DFS와 BFS
굳이 정렬을? #include #include #include #include //#include using namespace std;using IntPair = pair;using ll = long long;IntPair nDir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우};int n, m, v;vector> g;vector vis;void DFS(int n = v){ vis[n] = true; cout q; q.push(v); vis[v] = true; while (!q.empty()) { int f = q.front(); q.pop(); cout > n >> m >> v; g.resize(n + 1); vis.resize(..
[실5] 11292 - 키 큰 사람
#include #include #include using namespace std;using IntPair = pair;using ll = long long;IntPair nDir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우};int main(){ int t; while (1) { cin >> t; if (t == 0) break; multimap m; float mx = 0.f; while (t--) { string str; float val; cin >> str >> val; m.insert({ val,str }); mx = max(mx, val); } auto range = m.equal_ra..
[실3] 9711 - 피보나치
#include #include #include using namespace std;using IntPair = pair;using ll = long long;#define MAX 10001ll dp[MAX];int main(){ dp[1] = dp[2] = 1; int t, c = 1; cin >> t; while (t--) { int p, q; cin >> p >> q; for (int i = 3; i
[실4] 2578 - 빙고
#include #include #include using namespace std;#define MAX 5int main(){ map, bool> board; map> pos; for (int y = 0; y > n; pos[n] = { y,x }; board[{y, x}] = false; } } for (int y = 0; y > n; board[pos[n]] = true; // 위에서 아래로 for (int x = 0; x = 3) { cout
[실4] 9372 - 상근이의 여행
#include using namespace std;int main(){ ios::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t--) { int n, m, a, b; cin >> n >> m; for (int i = 0; i > a >> b; cout
[실4] 11399 - ATM
#include #include #include using namespace std;int main(){ ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; vector v(n); for (int i = 0; i > v[i]; int ans = 0; sort(v.begin(), v.end()); for (int i = 0; i
[실3] 16967 - 배열 복원하기
#include #include #include #include #include #include using namespace std;//using IntPair = pair;int main() { int h, w, x, y; cin >> h >> w >> x >> y; vector> v(h + x, vector(w + y)); for (int i = 0; i > v[i][j]; } for (int i = x; i
[실4] 2217 - 로프
int input[100001];int n, ans;int main() { cin >> n; for (int i = 0; i > input[i]; sort(input, input + n); for (int i = 0; i