목록PS (94)
정화 코딩
https://www.acmicpc.net/problem/10174 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tn; cin >> tn; while (tn--) { string s; getline(cin, s); int n = s.length(); for (int i = 0; i = 'A' && s[i] 공백이 들어올 수 있기 때문에 string으로 받는 것이 아니라 한 줄 전체를 받아야 한다.C++ 한 줄 입력받기: getline(cin, s);근데 위의 코드를 돌리면 반복문이 n-1번..
https://www.acmicpc.net/problem/16953 #include #include #include using namespace std;int INTMAX = 1000000000;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, b; cin >> a >> b; queue> q; q.emplace(a, 0); int ans = -1; while (!q.empty()) { long long x = q.front().first; int cnt = q.front().second; q.pop(); if (x..
https://www.acmicpc.net/problem/2206 #include #include #include using namespace std;int dx[] = {1, -1, 0, 0};int dy[] = {0, 0, 1, -1};int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector> g(n, vector(m)); vector> chk(n, vector(m, 0)); for (int i = 0; i > s; for (int j = 0; j > q; // {x index, y index, didBreak, coun..
https://www.acmicpc.net/problem/2096 #include #include using namespace std;int const INTMAX = 1000000000;int const MAX_N = 100000;int m[MAX_N][3];int dpmax[2][3];int dpmin[2][3];int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i > m[i][j]; } } for (int j = 0; j 처음에는 dp 배열을 n * 3으로 선언했었는데 메모리 초과가 났었다. (MLE) 생각해보니 d..
https://www.acmicpc.net/problem/1987 #include #include using namespace std;int r, c;vector m;bool vst[26];int maxc = 0;int di[] = {1, -1, 0, 0};int dj[] = {0, 0, 1, -1};void dfs(int curi, int curj, int cnt) { if (cnt > maxc) maxc = cnt; for (int k = 0; k = 0 && nxti = 0 && nxtj > r >> c; m = vector(r); for (int i = 0; i > m[i]; } vst[m[0][0] - 'A'] = true; dfs(0, 0, 1); ..
https://www.acmicpc.net/problem/2448 #include #include #include using namespace std;int n;vector> ans;void recur(int si, int ni, int sj, int nj) { if (ni == 3) { ans[si][sj + 2] = '*'; ans[si + 1][sj + 1] = '*'; ans[si + 1][sj + 3] = '*'; ans[si + 2][sj] = '*'; ans[si + 2][sj + 1] = '*'; ans[si + 2][sj + 2] = '*'; ans[si + 2][sj + 3] = '*'; ..
https://www.acmicpc.net/problem/1504 #include #include #include using namespace std;int INTMAX = 1000000;int n, e, v1, v2;vector>> edge;int dijkstra(int s, int e) { vector dst(n + 1, INTMAX); priority_queue> pq; dst[s] = 0; pq.emplace(0, s); while (!pq.empty()) { int cost = -pq.top().first; int cur = pq.top().second; pq.pop(); for (auto nxt: edge[cur]) ..
https://www.acmicpc.net/problem/1967 #include #include using namespace std;vector>> g;vector vst;int maxc = 0;void dfs(int cur, int cnt) { vst[cur] = true; if (cnt > maxc) maxc = cnt; for (auto nxt: g[cur]) { if (!vst[nxt.first]) dfs(nxt.first, cnt + nxt.second); }}int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; g = vector..