2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)

J题队友犯了初始化的错,白给6发,本来能1A的



B:

solver:lzh、czq

就是个拓扑排序

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define ff first
 4 #define ss second
 5 #define mp make_pair
 6 typedef long long ll;
 7 typedef pair<int, int> pii;
 8
 9 vector<int> g[400010];
10 vector<int> v;
11 int a[400010], deg[400010];
12 int main() {
13     v.push_back(0);
14     int n;
15     scanf("%d", &n);
16     for (int i = 0; i < n; i++) {
17         int j;
18         scanf("%d%d", &a[i], &j);
19         while (j--) {
20             int x;
21             scanf("%d", &x);
22             g[i].push_back(x - 1);
23             deg[x - 1]++;
24         }
25     }
26     int ans = 0;
27     priority_queue<pii> pq;
28     for (int i = 0; i < n; i++)
29         if (!deg[i]) pq.push(mp(-a[i], i));
30     while (!pq.empty()) {
31         pii x = pq.top();
32         pq.pop();
33         v.push_back(-x.ff);
34         for (auto i : g[x.ss]) {
35             deg[i]--;
36             if (!deg[i])
37                 pq.push(mp(-a[i], i));
38         }
39     }
40     reverse(v.begin(), v.end());
41     for (int i = 0; i < n; i++) ans = max(ans, v[i] + i);
42     printf("%d\n", ans);
43 }

C:

solver:czq

直接把圆周切个1000份

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define pb emplace_back
 6 #define mp make_pair
 7 #define eps 1e-8
 8 #define lson (curpos<<1)
 9 #define rson (curpos<<1|1)
10 /* namespace */
11 using namespace std;
12 /* header end */
13
14 const int maxn = 1010;
15 const double pi = acos(-1);
16 vector<pair<double, double>>ans;
17 vector<int>g[maxn];
18 int n, __size[maxn];
19
20 void dfs(int u, int father, double angle) {
21     __size[u]++;
22     for (auto v : g[u]) {
23         if (v != father) {
24             ans[v].first = ans[u].first + cos(angle);
25             ans[v].second = ans[u].second + sin(angle);
26             dfs(v, u, angle);
27             __size[u] += __size[v];
28             angle += pi / maxn * __size[v];
29         }
30     }
31 }
32
33 int main() {
34     scanf("%d", &n);
35     ans.resize(n + 1);
36     for (int i = 1; i < n; i++) {
37         int u, v; scanf("%d%d", &u, &v);
38         g[u].pb(v), g[v].pb(u);
39     }
40     dfs(1, -1, 0);
41     for (int i = 1; i <= n; i++) printf("%.10f %.10f\n", ans[i].first, ans[i].second);
42     return 0;
43 }

G:

solver:lzh、zyh

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define ff first
 4 #define ss second
 5 typedef long long ll;
 6 typedef pair<int, int> pii;
 7
 8 char s[30];
 9 int notuse[30];
10 const int dd[4][2] = { -1, 0, 1, 0, 0, 1, 0, -1 };
11 const int C[4][2] = { 0, 1, 1, 0, 2, 3, 3, 2 };
12 const char fa[] = { "LRUD" };
13 int main() {
14     scanf("%s", s + 1);
15     int n = strlen(s + 1);
16     if (n == 1) {
17         if (s[1] == ‘L‘)
18             printf("1 0\n0\n");
19         else if (s[1] == ‘R‘)
20             printf("-1 0\n0\n");
21         else if (s[1] == ‘U‘)
22             printf("0 -1\n0\n");
23         else
24             printf("0 1\n0\n");
25         return 0;
26     }
27     for (int j = 0; j <= 4; j += 2) {
28         vector<int> tmp;
29         for (int i = 1; i <= n; i++)
30             if (s[i] == fa[j] || s[i] == fa[j + 1])
31                 tmp.push_back(i);
32         for (int i = tmp.size() - 3; i >= 0; i--)
33             if (tmp[i] + 1 == tmp[i + 1] && tmp[i + 1] + 1 == tmp[i + 2])
34                 notuse[tmp[i]]++;
35     }
36     for (int j = 0; j <= 4; j += 2) {
37         int tmp = 0;
38         for (int i = n; i >= 1; i--)
39             if (s[i] == fa[j] || s[i] == fa[j + 1])
40                 tmp++;
41             else
42                 break;
43         if (tmp >= 3) {
44             printf("impossible\n");
45             return 0;
46         }
47     }
48
49     vector<pii> ans;
50     pii cur = { 0, 0 };
51     int step = n + 1;
52     for (int i = n; i >= 1; i--)
53         if (!notuse[i]) {
54             for (int j = 0; j < 4; j++)
55                 if (s[i] == fa[j]) {
56                     if (i != n)
57                         ans.push_back({ cur.ff + dd[j][0], cur.ss + dd[j][1] });
58
59                     pii tmp = { (1 << step) *(-dd[j][0]), (1 << step) *(-dd[j][1]) };
60                     if (tmp.ff)
61                         cur.ff += tmp.ff;
62                     else
63                         cur.ss += tmp.ss;
64                 }
65             step--;
66         }
67     printf("%d %d\n%d\n", cur.ff, cur.ss, ans.size());
68     for (auto i : ans)
69         printf("%d %d\n", i.ff, i.ss);
70 }

H:

solver:zyh、lzh

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 bool z[1000001];
 4 int main() {
 5     int n, c, b;
 6     scanf("%d%d%d", &n, &c, &b);
 7     for (int i = 0; i < b; ++i) {
 8         int t;
 9         scanf("%d", &t);
10         z[t - 1] = true;
11     }
12     int now = 0;
13     if (c & 1) {
14         now = 1;
15         c++;
16     }
17     for (int i = 0; i < n; ++i) {
18         if (z[i] || !c) printf("0");
19         else {
20             printf("%d", now);
21             c--;
22             now = 1 - now;
23         }
24     }
25 }

I:

solver:czq

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define pb emplace_back
 6 #define mp make_pair
 7 #define eps 1e-8
 8 #define lson (curpos<<1)
 9 #define rson (curpos<<1|1)
10 /* namespace */
11 using namespace std;
12 /* header end */
13
14 const int maxn = 2e5 + 10;
15 int n, a[maxn];
16 double ans = INT_MAX;
17
18 int main() {
19     scanf("%d", &n);
20     for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
21     sort(a + 1, a + 1 + n);
22     for (int i = 1; i <= n; i++) {
23         if (a[i] > i) return puts("-1"), 0;
24         ans = min(ans, double(a[i]) / (i));
25     }
26     printf("%.10f\n", ans);
27     return 0;
28 }

J:

solver:zyh、czq

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 long long p[200001];
 4 int main() {
 5     int n;
 6     scanf("%d", &n);
 7     for (int i = 1; i <= n; ++i) scanf("%lld", &p[i]);
 8     sort(p + 1, p + n + 1);
 9     p[0] = -1;
10     if (p[n] == p[n - 1]) {
11         printf("%lld\n", p[n] - p[n - 2]); return 0;
12     }
13     long long sum = p[n] - p[n - 1];
14     long long Last = p[n - 1];
15     long long maxT = __LONG_LONG_MAX__;
16     long long T = 1;
17     long long ans = 0;
18     int tot = 0;
19     for (int i = n - 1; i >= 1; --i) {
20         ++tot;
21         if (p[i] != p[i - 1]) {
22             if (maxT >= Last - p[i]) {
23                 ans += T * (Last - p[i]);
24                 sum -= (T - 1) * (Last - p[i]);
25                 T = int(log2(tot)) + 1;
26                 if (T > 1) maxT = sum / (T - 1);
27                 else maxT = sum + 1;
28                 Last = p[i];
29             } else break;
30         }
31     }
32     if (T > 1) ans += T * maxT + sum % (T - 1);
33     else ans += T * maxT;
34     printf("%lld", ans);
35     return 0;
36 }

K:

solver:czq

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define pb emplace_back
 6 #define mp make_pair
 7 #define eps 1e-8
 8 #define lson (curpos<<1)
 9 #define rson (curpos<<1|1)
10 /* namespace */
11 using namespace std;
12 /* header end */
13
14 int n, m;
15 string a, b, tmp, ans = "";
16
17 int main() {
18     ios::sync_with_stdio(false);
19     cin.tie(0);
20     cin >> n >> m >> a >> b;
21     tmp = a;
22     reverse(b.begin(), b.end());
23     reverse(tmp.begin(), tmp.end());
24     int p = 0;
25     for (int i = 0; i < m - n; i++) {
26         int x = b[i] - tmp[p]; if (x < 0) x += 26;
27         ans += (char)(x + ‘a‘);
28         tmp += ans[p++];
29     }
30     tmp += a;
31     reverse(ans.begin(), ans.end());
32     cout << ans << a << endl;
33     return 0;
34 }

原文地址:https://www.cnblogs.com/JHSeng/p/12336837.html

时间: 2024-10-05 08:28:27

2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)的相关文章

2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016) 个人题解

Problem C Careful Ascent 可怜的我们被卡在了签到题上,当时用的二分来做,结果速度的左右区间写成了[0,1e32],而改成[-1e32,1e32]就通过了,哎-,怎么就没想到去改一下区间的范围呢. 下面是正常的数学解法,类似于解一元一次方程. #include <iostream> using namespace std; typedef long long ll; ll x,y,n; ll a,b;double c; int main(){ cin>>x&g

2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018) Solution

A. Numbers Unsolved. B. Broken Watch Solved. 题意: 一个圆盘上,有等分的n块区域,有三根指针,当三根指针分别位于两块区域的交界处时 指针的三点相连会形成一个三角形,求有多少个三角包含三指针的起点(即交汇处) 思路: 1 #include<bits/stdc++.h> 2 3 using namespace std; 4 5 typedef unsigned long long ull; 6 typedef long long ll; 7 8 ll

2019-2020 ICPC Southwestern European Regional Programming Contest (SWERC 2019-2020)

J想到了卡特兰数,也想到要按最小值分割数组,丢给队友之后两个人都没做出来,傻了 题目链接:https://codeforces.com/gym/102501 B: solver:czq 1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define pb emplace_back 6 #define mp make_pair 7 #define eps 1e-8 8

2004-2005 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2004)

https://codeforc.es/gym/101461 5题结束了,可能是只打了3个小时吧.要是E试试Java8去用高精浮点二分,或者坚持读下来发现F是个割点模板题?以后可能远古场还是不打了,要拉2015年以内的. D - City Game 悬线法求最大非1子矩阵,根据up[i][j]=(g[i][j]==0)?0:up[i-1][j]+1预处理出悬线.然后每一行用单调栈扫.注意悬线法,某个元素被弹出之后,弹出他的元素会继承他的管辖范围!所以当时的办法是弄两个栈,一个栈存单调递增的悬线下

(寒假GYM开黑)2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)

layout: post title: 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces 传送门 付队! B.Baby Bites (签到模拟) 按照题意模拟就行了 int a[maxn]; string s; int main() { std::ios::syn

训练20191007 2017-2018 ACM-ICPC Latin American Regional Programming Contest

2017-2018 ACM-ICPC Latin American Regional Programming Contest 试题地址:http://codeforces.com/gym/101889 总体情况 总共通过7题CEFGHIJ.其中我完成HIJ三题.纯属被大佬带飞系列. 解题报告 H - Hard choice 签到题 #include <bits/stdc++.h> using namespace std; int a1,b1,c1,a2,b2,c2; int main() {

Northwestern European Regional Contest 2017-I题- Installing Apps题解

一.题意 有一个手机,容量为$C$,网上有$N$个app,每个app有个安装包大小$d_i$,有个安装后的占用空间大小$s_i$,安装app是瞬间完成的,即app的占用空间可以瞬间由$d_i$变成$s_i$,而不需要其他多余的空间.问这个手机最多可以安装多少个app,输出最多可以安装的app数量和安装顺序. 二.思路 很显然的$dp$.按照$max(d,s)-s$从大到小排序.$dp[i][j]$表示在前$i$个app中,占用空间不超过$j$的条件下最多可以安装的app的数量.那么,有如下递推式

2017-2018 Northwestern European Regional Contest (NWERC 2017)

Rank Solved A B C D E F G H I J K --/-- 6/11 . O . O . . O O O . O O: 当场通过 ?: 赛后通过 .: 尚未通过 A Ascending Photo unsolved B Boss Battle solved by chelly chelly's solution C Connect the Dots unsolved D Dunglish solved by ABerror ABerror's solution E Engli

2017-2018 ACM-ICPC Latin American Regional Programming Contest Solution

A - Arranging tiles 留坑. B - Buggy ICPC 题意:给出一个字符串,然后有两条规则,如果打出一个辅音字母,直接接在原字符串后面,如果打出一个元音字母,那么接在原来的字符串后面之后再翻转整个字符串,在这两条规则之下,求有多少种打印给定字符串的方法 思路:如果第一个字符是辅音,那么答案为0 如果全是辅音或全是元音,那么答案为1 如果只有一个辅音,答案为len 否则是最中间两个元音中间的辅音字符个数+1 1 #include <bits/stdc++.h> 2 3 u