题目链接  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 second typedef 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 second typedef 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;
}

  

最新文章

  1. MATLAB中fft函数的正确使用方法
  2. IOS Animation-Sprite Kit(一)基础
  3. linux远程复制和压缩文件的命令
  4. PAT (Basic Level) Practise:1022. D进制的A+B
  5. [Android自定义控件] Android自定义控件
  6. eclipse中建python项目并运行
  7. 关于ajax后台success传来json数据的问题
  8. 数据结构 - 表插入排序 具体解释 及 代码(C++)
  9. CentOS与Win7远程桌面互通
  10. Boostnote 为程序员的开源式记事本
  11. C++ 模式设计
  12. 阿里的Json解析包FastJson使用
  13. Ubuntu16下用virtualbox 安装Windows虚拟机
  14. c语言连接mysql数据库的实现方法
  15. HDU 1789 - Doing Homework again - [贪心+优先队列]
  16. 【LG3240】[HNOI2015]实验比较
  17. javascript获取当前日期和时间
  18. 全球免费知名DNS服务器
  19. UVa 12093 Protecting Zonk (树形DP)
  20. 以源码编译的方式安装PHP与php-fpm

热门文章

  1. PAT (Basic Level) Practise (中文)-1029. 旧键盘(20)
  2. Vue 2.0 项目在IE下显示空白
  3. 王小胖之 Base64编码/解码
  4. leepcode作业解析 - 5-19
  5. 安装tesserocr的步骤和报错RuntimeError: Failed to init API, possibly an invalid tessdata path解决办法
  6. teatime、
  7. Python9-函数-day9
  8. Lex与Yacc学习(八)之变量和有类型的标记(扩展计算器)
  9. PAT Basic 1050
  10. PAT Basic 1044