zoukankan      html  css  js  c++  java
  • BZOJ 2083: [Poi2010]Intelligence test( )

    写了个暴力...然后就AC了...

    记录每个数出现的位置, 然后每次询问用二分暴力匹配...极端情况可以卡到O(m²logm)...

    #include<bits/stdc++.h>
    
    using namespace std;
    
    const int maxn = 1000009;
    
    vector<int> pos[maxn];
    int N;
    
    int main() {
    	
    	cin >> N;
    	for(int i = 0; i < N; i++) {
    		int t; scanf("%d", &t);
    		pos[t].push_back(i);
    	}
    	cin >> N;
    	while(N--) {
    		int len; scanf("%d", &len);
    		bool ok = true;
    		int p = -1;
    		for(int i = 0; i < len; i++) {
    			int t; scanf("%d", &t);
    			if(!ok) continue;
    			vector<int>::iterator c = upper_bound(pos[t].begin(), pos[t].end(), p);
    			if(c != pos[t].end())
    			    p = *c;
    			else
    			    ok = false;
    		}
    		puts(ok ? "TAK" : "NIE");
    	}
    	
    	return 0;
    }
    

      

    2083: [Poi2010]Intelligence test

    Time Limit: 10 Sec  Memory Limit: 259 MB
    Submit: 300  Solved: 134
    [Submit][Status][Discuss]

    Description

    霸中智力测试机构的一项工作就是按照一定的规则删除一个序列的数字,得到一个确定的数列。Lyx很渴望成为霸中智力测试机构的主管,但是他在这个工作上做的并不好,俗话说熟能生巧,他打算做很多练习,所以他希望你写一个程序来快速判断他的答案是否正确。

    Input

    第一行为一个整数m(1<=m<=1000000)第二行包括m个用空格分开的整数ai(1<=ai<=1000000),组成了最初的序列,第三行为一个整数n(1<=n<=1000000),表示n个Lyx经过一系列删除得到的序列,每个序列两行,第一行给出长度L(1<=L<=m),然后下一行为L个由空格分开的整数bi(1<=bi<=1000000)。

    Output

    共n行,如果Lyx的序列确实是由最初的序列删除一些数得到,就输出TAK,否则输出NIE。

    Sample Input

    7
    1 5 4 5 7 8 6
    4
    5
    1 5 5 8 6
    3
    2 2 2
    3
    5 7 8
    4
    1 5 7 4

    Sample Output

    TAK
    NIE
    TAK
    NIE

    HINT

     

    Source

      

  • 相关阅读:
    苹果一体机发射Wi-Fi
    iphone 屏蔽系统自动更新,消除设置上的小红点
    data parameter is nil 异常处理
    copy与mutableCopy的区别总结
    java axis2 webservice
    mysql 远程 ip访问
    mysql 存储过程小问题
    mysql游标错误
    is not writable or has an invalid setter method错误的解决
    Struts2中关于"There is no Action mapped for namespace / and action name"的总结
  • 原文地址:https://www.cnblogs.com/JSZX11556/p/4728670.html
Copyright © 2011-2022 走看看