zoukankan      html  css  js  c++  java
  • 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		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
    ", 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;
    }
    

      

  • 相关阅读:
    Ubuntu下SVN命令行递归加入文件夹文件(免去一个一个的加入 --force)
    oschina插件和扩展
    oschina iOS代码库
    oschina 开发工具
    oschina应用工具
    oschina程序开发
    网络爬虫 kamike.collect
    WebFetch 是无依赖极简网页爬取组件
    commoncrawl 源码库是用于 Hadoop 的自定义 InputFormat 配送实现
    JAVA平台上的网络爬虫脚本语言 CrawlScript
  • 原文地址:https://www.cnblogs.com/cxhscst2/p/7594648.html
Copyright © 2011-2022 走看看