在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
A. Broken Clock
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59. You are given a time in format HH:MM that is currently displayed on the broken clock. Your goal is to change minimum number of digits in order to make clocks display the correct time in the given format. For example, if 00:99 is displayed, it is enough to replace the second 9 with 3 in order to get 00:39 that is a correct time in 24-hours format. However, to make 00:99 correct in 12-hours format, one has to change at least two digits. Additionally to the first change one can replace the second 0 with 1 and obtain 01:39. Input
The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively. The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes. Output
The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them. Examples
Input
24 Output
17:30 Input
12 Output
07:30 Input
24 Output
09:09 1 /****************************** 2 code by drizzle 3 blog: www.cnblogs.com/hsd-/ 4 ^ ^ ^ ^ 5 O O 6 ******************************/ 7 #include<bits/stdc++.h> 8 #include<map> 9 #include<set> 10 #include<cmath> 11 #include<queue> 12 #include<bitset> 13 #include<math.h> 14 #include<vector> 15 #include<string> 16 #include<stdio.h> 17 #include<cstring> 18 #include<iostream> 19 #include<algorithm> 20 #pragma comment(linker, "/STACK:102400000,102400000") 21 using namespace std; 22 #define A first 23 #define B second 24 const int mod=1000000007; 25 const int MOD1=1000000007; 26 const int MOD2=1000000009; 27 const double EPS=0.00000001; 28 //typedef long long ll; 29 typedef __int64 ll; 30 const ll MOD=1000000007; 31 const int INF=1000000010; 32 const ll MAX=1ll<<55; 33 const double eps=1e-5; 34 const double inf=~0u>>1; 35 const double pi=acos(-1.0); 36 typedef double db; 37 typedef unsigned int uint; 38 typedef unsigned long long ull; 39 int what; 40 char a[10]; 41 int main() 42 { 43 scanf("%d",&what); 44 getchar(); 45 scanf("%s",a); 46 if(what==24) 47 { 48 int s,t; 49 s=(a[0]-'0')*10+(a[1]-'0'); 50 t=(a[3]-'0')*10+(a[4]-'0'); 51 //cout<<s<<" "<<t<<endl; 52 if(s>23) 53 a[0]='0'; 54 if(t>59) 55 a[3]='0'; 56 } 57 else 58 { 59 int s,t; 60 s=(a[0]-'0')*10+a[1]-'0'; 61 t=(a[3]-'0')*10+a[4]-'0'; 62 if(s==0) 63 a[0]='1'; 64 if(s>12) 65 { 66 if(a[1]=='0') 67 a[0]='1'; 68 else 69 a[0]='0'; 70 } 71 if(t>59) 72 a[3]='0'; 73 } 74 cout<<a<<endl; 75 return 0; 76 }
B. Verse Pattern
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters. We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'. Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored. The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi. You are given the text and the verse pattern. Check, if the given text matches the given verse pattern. Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of lines in the text. The second line contains integers p1, ..., pn (0 ≤ pi ≤ 100) — the verse pattern. Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters. Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes). Examples
Input
3 Output
YES Input
4 Output
NO Input
4 Output
YES Note
In the first sample, one can split words into syllables in the following way: in-tel Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. 题意:统计aeiouy的个数 一 一对应则输出YES 否则输出NO 题解:模拟 1 /****************************** 2 code by drizzle 3 blog: www.cnblogs.com/hsd-/ 4 ^ ^ ^ ^ 5 O O 6 ******************************/ 7 #include<bits/stdc++.h> 8 #include<map> 9 #include<set> 10 #include<cmath> 11 #include<queue> 12 #include<bitset> 13 #include<math.h> 14 #include<vector> 15 #include<string> 16 #include<stdio.h> 17 #include<cstring> 18 #include<iostream> 19 #include<algorithm> 20 #pragma comment(linker, "/STACK:102400000,102400000") 21 using namespace std; 22 #define A first 23 #define B second 24 const int mod=1000000007; 25 const int MOD1=1000000007; 26 const int MOD2=1000000009; 27 const double EPS=0.00000001; 28 //typedef long long ll; 29 typedef __int64 ll; 30 const ll MOD=1000000007; 31 const int INF=1000000010; 32 const ll MAX=1ll<<55; 33 const double eps=1e-5; 34 const double inf=~0u>>1; 35 const double pi=acos(-1.0); 36 typedef double db; 37 typedef unsigned int uint; 38 typedef unsigned long long ull; 39 int n; 40 int a[105]; 41 char b[105][105]; 42 map<char,int>mp; 43 int main() 44 { 45 mp['a']=1; 46 mp['e']=1; 47 mp['i']=1; 48 mp['o']=1; 49 mp['u']=1; 50 mp['y']=1; 51 scanf("%d",&n); 52 int flag=0; 53 memset(b,0,sizeof(b)); 54 for(int i=1;i<=n;i++) 55 scanf("%d",&a[i]); 56 getchar(); 57 for(int i=1;i<=n;i++) 58 { 59 gets(b[i]); 60 int ans=0; 61 int len=strlen(b[i]); 62 for(int j=0;j<len;j++) 63 { 64 if(mp[b[i][j]]) 65 ans++; 66 } 67 if(ans!=a[i]) 68 flag=1; 69 } 70 if(flag) 71 cout<<"NO"<<endl; 72 else 73 cout<<"YES"<<endl; 74 return 0; 75 }
C. Destroying Array
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to n defining the order elements of the array are destroyed. After each element is destroyed you have to find out the segment of the array, such that it contains no destroyed elements and the sum of its elements is maximum possible. The sum of elements in the empty segment is considered to be 0. Input
The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the length of the array. The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109). The third line contains a permutation of integers from 1 to n — the order used to destroy elements. Output
Print n lines. The i-th line should contain a single integer — the maximum possible sum of elements on the segment containing no destroyed elements, after first i operations are performed. Examples
Input
4 Output
5 Input
5 Output
6 Input
8 Output
18 Note
Consider the first sample:
题意:给你n个数 并给出删除这n个数的次序 对于每次删除 输出连续区间(不包括删除的位置的数)的和的最大值 题解:逆向来思考 正向的删除 当作逆向的增加 每增加一个数 判断是否与已知的集合相邻 或者作为新的集合 取max输出 并查集处理 1 /****************************** 2 code by drizzle 3 blog: www.cnblogs.com/hsd-/ 4 ^ ^ ^ ^ 5 O O 6 ******************************/ 7 #include<bits/stdc++.h> 8 #include<map> 9 #include<set> 10 #include<cmath> 11 #include<queue> 12 #include<bitset> 13 #include<math.h> 14 #include<vector> 15 #include<string> 16 #include<stdio.h> 17 #include<cstring> 18 #include<iostream> 19 #include<algorithm> 20 #pragma comment(linker, "/STACK:102400000,102400000") 21 using namespace std; 22 #define A first 23 #define B second 24 const int mod=1000000007; 25 const int MOD1=1000000007; 26 const int MOD2=1000000009; 27 const double EPS=0.00000001; 28 //typedef long long ll; 29 typedef __int64 ll; 30 const ll MOD=1000000007; 31 const int INF=1000000010; 32 const ll MAX=1ll<<55; 33 const double eps=1e-5; 34 const double inf=~0u>>1; 35 const double pi=acos(-1.0); 36 typedef double db; 37 typedef unsigned int uint; 38 typedef unsigned long long ull; 39 int n; 40 ll a[100005]; 41 ll s[100005]; 42 int used[100005]; 43 int pos[100005]; 44 int fa[100005]; 45 ll re[100005]; 46 int find(int root) 47 { 48 if(fa[root]!=root) 49 fa[root]=find(fa[root]); 50 return fa[root]; 51 } 52 void uni(int a,int b) 53 { 54 int aa=find(a); 55 int bb=find(b); 56 if(aa!=bb) 57 { 58 fa[aa]=bb; 59 s[bb]+=s[aa]; 60 } 61 } 62 int main() 63 { 64 scanf("%d",&n); 65 for(int i=1; i<=n; i++) 66 { 67 scanf("%I64d",&a[i]); 68 fa[i]=i; 69 } 70 for(int i=1; i<=n; i++) 71 scanf("%d",&pos[i]); 72 ll ans=0; 73 for(int i=n; i>=1; i--) 74 { 75 s[pos[i]]=a[pos[i]]; 76 used[pos[i]]=1; 77 if(pos[i]<n&&used[pos[i]+1]) 78 uni(pos[i],pos[i]+1); 79 if(pos[i]>1&&used[pos[i]-1]) 80 uni(pos[i],pos[i]-1); 81 re[i]=ans; 82 ans=max(ans,s[find(pos[i])]); 83 } 84 for(int i=1; i<=n; i++) 85 printf("%I64d\n",re[i]); 86 return 0; 87 }
D. Generating Sets
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given a set Y of n distinct positive integers y1, y2, ..., yn. Set X of n distinct positive integers x1, x2, ..., xn is said to generate set Y if one can transform X to Y by applying some number of the following two operation to integers in X:
Note that integers in X are not required to be distinct after each operation. Two sets of distinct integers X and Y are equal if they are equal as sets. In other words, if we write elements of the sets in the array in the increasing order, these arrays would be equal. Note, that any set of integers (or its permutation) generates itself. You are given a set Y and have to find a set X that generates Y and the maximum element of X is mininum possible. Input
The first line of the input contains a single integer n (1 ≤ n ≤ 50 000) — the number of elements in Y. The second line contains n integers y1, ..., yn (1 ≤ yi ≤ 109), that are guaranteed to be distinct. Output
Print n integers — set of distinct integers that generate Y and the maximum element of which is minimum possible. If there are several such sets, print any of them. Examples
Input
5 Output
4 5 2 3 1 Input
6 Output
12 13 14 7 3 1 Input
6 Output
4 5 2 6 3 1 1 /****************************** 2 code by drizzle 3 blog: www.cnblogs.com/hsd-/ 4 ^ ^ ^ ^ 5 O O 6 ******************************/ 7 #include<bits/stdc++.h> 8 #include<map> 9 #include<set> 10 #include<cmath> 11 #include<queue> 12 #include<bitset> 13 #include<math.h> 14 #include<vector> 15 #include<string> 16 #include<stdio.h> 17 #include<cstring> 18 #include<iostream> 19 #include<algorithm> 20 #pragma comment(linker, "/STACK:102400000,102400000") 21 using namespace std; 22 #define A first 23 #define B second 24 const int mod=1000000007; 25 const int MOD1=1000000007; 26 const int MOD2=1000000009; 27 const double EPS= 全部评论
专题导读
上一篇:加载rocksdb实例报错:java.lang.UnsatisfiedLinkError:C:\Users\Administrator\AppDa ...发布时间:2022-07-14下一篇:.NETC#基础(5):结构体-高性能代码的基石发布时间:2022-07-14热门推荐
热门话题
阅读排行榜
|
请发表评论