목록PS (96)
정화 코딩
https://www.acmicpc.net/problem/15889 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector loc = vector(n); vector avl = vector(n - 1); for (int i = 0; i > loc[i]; } for (int i = 0; i > avl[i]; } if (n == 1) { cout 0; i--) { if (loc[i] + avl[i] >= nxt) { ..
https://www.acmicpc.net/problem/17386 #pythonimport sysinput = sys.stdin.readlinex1, y1, x2, y2 = map(int, input().split())x3, y3, x4, y4 = map(int, input().split())def ccw(x1, y1, x2, y2, x3, y3): ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 * y2 + x1 * y3) if ccw > 0: return 1 elif ccw ccw의 결과값을 통해 세 점의 위치 관계를 파악할 수 있다.ccw = (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 ..
#include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector> data (n); vector ans = vector(n); for (int i = 0; i > data[i].first; data[i].second = i; } sort(data.begin(), data.end()); int cnt = 0; int tmp = 0; ans[data[0].second] = 0; int pre = data[0].first; for (in..
https://www.acmicpc.net/problem/1074 #include #include #include using namespace std;int cnt = 0;vector> m;void search(int sx, int sy, int size) { if (size == 1) { m[sy][sx] = cnt++; return; } int div = size / 2; search(sx, sy, div); search(sx + div, sy, div); search(sx, sy + div, div); search(sx + div, sy + div, div);}int main() { ios_base::sync_with_stdio(0..
가장 긴 증가하는 부분 수열 (백준 11053번) https://www.acmicpc.net/problem/11053 import sysinput = sys.stdin.readlinen = int(input())a = list(map(int, input().split()))dp = [0 for _ in range(n)]maxa = 0for i in range(n): maxt = 0 for j in range(i): if a[i] > a[j]: maxt = max(maxt, dp[j]) dp[i] = maxt + 1 maxa = max(maxa, dp[i])print(maxa)dp[i] : 0부터 i까지 i를 포함하는 가장 길게 증가하는 수열의 길이앞의..
https://www.acmicpc.net/problem/21919 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector a = vector(n); for (int i = 0; i > a[i]; } int cnt = 0; long long ans = 1; for (int x: a) { //! bool isPrime = true; double tmp = sqrt(x); if (tmp * tmp == x) { ..
https://www.acmicpc.net/problem/11723 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m, n; string op; cin >> m; int now = 0; for (int i = 0; i > op; if (op == "add") { cin >> n; now = now | (1 > n; if ((now & (1 > n; if ((now & (1 > n; now = now ^ (1 (정답) 비트..
https://www.acmicpc.net/problem/1012 #include #include #include using namespace std;int dn[4] = {0, 0, -1, 1};int dm[4] = {-1, 1, 0, 0};int m, n, k;int cnt = 0;vector> g;void bfs(vector start) { queue> q; cnt++; q.push(start); g[start[0]][start[1]] = 0; while (!q.empty()) { vector cur = q.front(); q.pop(); for (int i = 0; i = 0 && tn = 0 && tm > tn; for (in..