标签:print res namespace test bsp nal header possible 直接
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 }
2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)
标签:print res namespace test bsp nal header possible 直接
原文地址:https://www.cnblogs.com/JHSeng/p/12336837.html