Codeforces Round #264 (Div. 2)_html/css_WEB-ITnose
Codeforces Round #264 (Div. 2)
Question link
A: Pay attention to the situation where the special judgment is just right, and for the rest, just judge the maximum value of the record one by one
B : Scan it once, fill it with money if there is not enough, and record the excess energy
C: Process the main and secondary diagonals, and then only choose the largest one for black and white squares.
D: Transformed into a DAG longest path problem, record the position of each number in each sequence. If a number can be placed, then the number in each sequence must be at the end of the previous sequence. Behind the number
E: Work hard, pre-process the tree, and then find a matching one from the current position upwards for each query. If there is no matching one, it will be -1
Code:
A:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n, s;int main() { scanf("%d%d", &n, &s); int x, y; int flag = 1; int ans = 0; for (int i = 0; i < n; i++) { scanf("%d%d", &x, &y); if (x == s) { if (y == 0) { ans = max(ans, y); flag = 0; } } else if (x < s) { ans = max(ans, (100 - y) % 100); flag = 0; } } if (flag) printf("-1\n"); else printf("%d\n", ans); return 0;}
B:
#include <cstdio>#include <cstring>const int N = 100005;typedef long long ll;int n;ll h[N];int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld", &h[i]); ll now = 0; ll ans = 0; for (int i = 1; i <= n; i++) { if (h[i] > h[i - 1]) { ll need = h[i] - h[i - 1]; if (now >= need) { now -= need; } else { ans += need - now; now = 0; } } else { now += h[i - 1] - h[i]; } } printf("%lld\n", ans); return 0;}
C:
#include <cstdio>#include <cstring>const int N = 2005;typedef long long ll;int n;ll g[N][N], zhu[N + N], fu[N + N];int main() { scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%lld", &g[i][j]); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { zhu[i - j + n] += g[i][j]; fu[i + j] += g[i][j]; } } ll b = -1, w = -1; int bx, by, wx, wy; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ll sum = zhu[i - j + n] + fu[i + j] - g[i][j]; if ((i + j) % 2 == 0) { if (b < sum) { b = sum; bx = i + 1; by = j + 1; } } else { if (w < sum) { w = sum; wx = i + 1; wy = j + 1; } } } } printf("%lld\n", b + w); printf("%d %d %d %d\n", bx, by, wx, wy); return 0;}
D:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 1005;struct Num { int v[10], la;} num[N];bool cmp(Num a, Num b) { return a.la < b.la;}int n, k, dp[N][N];bool judge(int i, int j) { for (int x = 0; x < k; x++) { if (num[i].v[x] < num[j].v[x]) return false; } return true;}int main() { scanf("%d%d", &n, &k); for (int i = 0; i < k; i++) { int tmp; for (int j = 1; j <= n; j++) { scanf("%d", &tmp); num[tmp].v[i] = j; } } for (int i = 0; i <= n; i++) { int maxv = 0; for (int j = 0; j < k; j++) { maxv = max(maxv, num[i].v[j]); } num[i].la = maxv; } sort(num, num + n + 1, cmp); /* for (int i = 0; i <= n; i++) { for (int j = 0; j < k; j++) { printf("%d ", num[i].v[j]); } printf("\n"); }*/ for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { dp[i][j] = max(dp[i][j], dp[i - 1][j]); if (judge(i, j)) { dp[i][i] = max(dp[i][i], dp[i][j] + 1); } } } int ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, dp[n][i]); printf("%d\n", ans); return 0;}
E:
#include <cstdio>#include <cstring>#include <vector>using namespace std;const int N = 100005;int n, q, val[N], f[N];vector<int> g[N];void dfs(int u, int fa) { f[u] = fa; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (v == fa) continue; dfs(v, u); }}int gcd(int a, int b) { while (b) { int tmp = a % b; a = b; b = tmp; } return a;}int query(int u) { int v = val[u]; u = f[u]; while (u) { if (gcd(val[u], v) > 1) return u; u = f[u]; } return -1;}int main() { scanf("%d%d", &n, &q); for (int i = 1; i <= n; i++) scanf("%d", &val[i]); int u, v; for (int i = 1; i < n; i++) { scanf("%d%d", &u, &v); g[u].push_back(v); g[v].push_back(u); } dfs(1, 0); int tp, a, b; while (q--) { scanf("%d%d", &tp, &a); if (tp == 1) { printf("%d\n", query(a)); } else { scanf("%d", &b); val[a] = b; } } return 0;}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.
