2017 ACM/ICPC Asia Regional Qingdao Online 记录
生活随笔
收集整理的這篇文章主要介紹了
2017 ACM/ICPC Asia Regional Qingdao Online 记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接? Qingdao
Problem C
AC自動機還不會,暫時暴力水過。
#include <bits/stdc++.h>using namespace std;#define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i)const int N = 1e5 + 10;string s[N]; int T; int n; int ans;int main(){std::ios::sync_with_stdio(false);cin >> T;while (T--){cin >> n;int id;int maxv = 0;for(int i = 1; i <= n; i++) {cin >> s[i];if (s[i].size() > maxv) {maxv = s[i].size();id = i;}}ans = 1;rep(i, 1, n) if (s[id].find(s[i]) == -1){ ans = 0; break;}if (ans) cout << s[id] << endl;else cout << "No" << endl;}return 0; }?
Problem J
考慮直接用隊列保存待判斷的元素(出隊or not)
然后直接用鏈表模擬就可以了。
為什么比賽的時候我不會做呢
#include <bits/stdc++.h>using namespace std;#define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) #define MP make_pair #define fi first #define se secondtypedef long long LL;const int N = 1e5 + 10;struct node{int x, l, r; } a[N];int T; int n, ans; queue <int> q;int main(){scanf("%d", &T);while (T--){scanf("%d", &n);rep(i, 1, n){a[i].l = i - 1;scanf("%d", &a[i].x);a[i].r = i + 1;}a[0].r = 1;a[n + 1].l = n;a[0].x = 0;a[n + 1].x = 1e8;while (!q.empty()) q.pop();rep(i, 1, n) q.push(i);while (!q.empty()){int now = q.front(); q.pop();int suc = a[now].r;int pre = a[now].l;if (a[now].x > a[suc].x){q.push(pre);a[pre].r = a[suc].r;a[a[suc].r].l = pre;a[suc].l = pre;}}ans = 0;int now = a[0].r;while (now <= n){++ans;now = a[now].r;}printf("%d\n", ans);now = a[0].r;while (now <= n){printf("%d ", a[now].x);now = a[now].r;}putchar(10);}return 0; }?
Problem K
簽到
#include <bits/stdc++.h>using namespace std;#define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) #define MP make_pair #define fi first #define se secondtypedef long long LL;LL a[1001000], b[1001000]; LL n; int T;int main(){for (LL i = 1; i <= 1000000; ++i) a[i] = i * i * i;rep(i, 1, 999999) b[i] = a[i + 1] - a[i];scanf("%d", &T);while (T--){scanf("%lld", &n);bool fl = false;rep(i, 1, 999999) if (b[i] == n){fl = true;break;}if (fl) puts("YES"); else puts("NO");} return 0; }
轉載于:https://www.cnblogs.com/cxhscst2/p/7594648.html
總結
以上是生活随笔為你收集整理的2017 ACM/ICPC Asia Regional Qingdao Online 记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: String的内存模型,为什么Strin
- 下一篇: 【Spring】详解spring事务属性