标签:CM ott tle int 构造 stream span input 重复数
题目:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6945 Accepted Submission(s): 3077
#include <iostream> void initial(int a[], int n) { for(int i = 0; i < n; i++) a[i] = -1; } void insert(int a[], int x) { int pos = 1; while(a[pos] != -1) { if(x < a[pos]) pos = 2*pos; else pos = 2*pos+1; } a[pos] = x; } bool isequal(int a[], int b[], int n) { for(int i = 0; i < n; i++) { if(a[i] != b[i]) return false; } return true; } int main() { using namespace std; int n; int N = 1000; int tree[N]; int test[N]; while(cin >> n && n != 0) { string str; cin >> str; initial(tree,N); for(int i = 0; i < str.length(); i++) insert(tree,str[i]-‘0‘); while(n--) { cin >> str; initial(test,N); for(int i = 0; i < str.length(); i++) insert(test,str[i]-‘0‘); bool ans = isequal(tree,test,N); if(ans) printf("YES\n"); else printf("NO\n"); } } return 0; }
标签:CM ott tle int 构造 stream span input 重复数
原文地址:https://www.cnblogs.com/w-j-c/p/9218908.html