The first stop of the acm_icpc Network Competition: Mudanjiang Division

Source: Internet
Author: User
Tags strcmp

Sad did not expect to make it look like this. Although it was not expected to qualify for the first team competition, three people spent a long time except two questions, question a was too watery to speak, it is generally solved within 5 minutes, and the fastest seems to be 2 minutes .. Shen shousu orz, question a is CHP's 1A, then he went to question C, and then searched for it several times with the BFS record path, then I lost my question C, and then I saw a huge part of question J. I decided to enumerate the water and Wa five times .. Then I typed H, TLE .. No .. After the event, students said it was a memory-based search? The entire lab didn't come up with questions like H ..

Question:

The Himalayas Time Limit: 2 seconds memory limit: 65536 KB

As an artist, Bob usually need to travel around the world. he made a lot of sketch of scenery on his journey. A famous spot he have visited recently is the Himalayas. the Himalayas is a mountain range in South Asia separating the plains of the Indian subcontinent from the Qinghai-Tibet Plateau. the Himalayas include over a hundred mountains exceeding 7,200 meters in elevation.

One day, Bob came up with an strange idea. he wanted to know the number of mountain peaks in his paintings. as his best friend, he turned to you for help. you are given a listNHeight Sampling ValuesHi. You shoshould determine how many peaks are there. For allIWhich satisfies 2 <=I<=N-1,HiIs defined as a peak if and only ifHi-1<Hi>Hi + 1.

Input

There are multiple test cases. The first line of input contains an integerTIndicating the number of test cases. For each test case:

The first line contains one integerN(1 <=N<= 50). The next line containsNIntegersHi(1 <=Hi<= 8844). It is guaranteed that any two adjacent height sampling values will be different.

Output

For each test case, output the number of peaks.

Sample Input
291 3 2 4 6 3 2 3 151 2 3 4 5
Sample output
30
Pure violence .. Headers

#include <iostream>#include <cstring>#include <cstdio>#include <cctype>#include <cstdlib>#include <algorithm>#include <set>#include <vector>#include <string>#include <cmath>#include <map>#include <queue>using namespace std;#define LL long longint a[55];int main(){int n,t;scanf("%d",&t);while(t--){   scanf("%d",&n);   for(int i=0;i<n;i++)scanf("%d",&a[i]);   int cnt=0;   for(int i=1;i<n-1;i++)if(a[i]>a[i-1]&&a[i]>a[i+1])cnt++;printf("%d\n",cnt);}return 0;}

Question J:


Pretty poem Time Limit: 2 seconds memory limit: 65536 KB

Poetry is a form of literature that uses aesthetic and rhythmic qualities of language. there are too famous poets in the contemporary era. it is said that a few ACM-ICPC contestants can even write poetic code. some poems has a strict rhyme scheme like "Ababa" or "ababcab ". for example, "niconiconi" is composed of a rhyme scheme "Ababa" with a = "Ni" and B = "CO ".

More technically, we call a poemPrettyIf it can be decomposed into one of the following rhyme scheme: "Ababa" or "ababcab". The symbolA,BAndCAre different continuous non-empty substrings of the poem. By the way, punctuation characters shoshould be ignored when considering the rhyme scheme.

You are given a line of poem, please determine whether it is pretty or not.

Input

There are multiple test cases. The first line of input contains an integerTIndicating the number of test cases. For each test case:

There is a line of PoemS(1 <= length (S) <= 50 ).SWill only contains alphabet characters or punctuation characters.

Output

For each test case, output "yes" if the poem is pretty, or "no" if not.

Sample Input
3niconiconi~pettan,pettan,tsurupettanwafuwafu
Sample output
YesYesNo

Brute force enumeration ..

# Include <iostream> # include <cstring> # include <cstdio> # include <cctype> # include <cstdlib> # include <algorithm> # include <set> # include <vector> # include <string> # include <cmath> # include <map> # include <queue> using namespace STD; # define ll long longchar STR [100]; bool is_ AB () {int Len = strlen (STR); For (INT I = 1; I <Len; I ++) // enumerate the length of a {int lB = len-3 * I; If (Lb <1) break; If (Lb % 2) continue; lb/= 2; if (Lb = I &&! Strncmp (STR, STR + I, I) // consider continue when A and B are the same; char T [555] = "\ 0"; strncat (T, STR, i); // astrncat (T, STR + I, LB); // bstrncat (T, STR, I); // astrncat (T, STR + I, LB ); // bstrncat (T, STR, I); // AIF (! Strcmp (STR, t) return 1;} return 0;} bool is_abc () {int Len = strlen (STR); For (INT I = 1; I <Len; I ++) // enumerate the length of A, B for (Int J = 1; j <Len; j ++) {int lc = len-3 * I-3 * J; if (LC <1) continue; if (I = J &&! Strncmp (STR, STR + I, I) continue; // consider the same as a and B if (I = Lc &&! Strncmp (STR, STR + 2 * I + 2 * J, I) continue; // consider the same if (j = Lc &&! Strncmp (STR + I, STR + 2 * I + 2 * j, j) continue; // consider the same char T as B and C [555] = "\ 0 "; strncat (T, STR, I); strncat (T, STR + I, j); strncat (T, STR, I); strncat (T, STR + I, j ); strncat (T, STR + 2 * I + 2 * j, LC); strncat (T, STR, I); strncat (T, STR + I, j); If (! Strcmp (STR, t) return 1;} return 0;} int main () {int T, P; char C; CIN> T; getchar (); while (t --) {P = 0; while (C = getchar ())! = '\ N') if (isalpha (c) STR [p ++] = C; STR [p] =' \ 0'; If (is_ AB () | is_abc () puts ("yes"); elseputs ("no");} return 0 ;}


The first stop of the acm_icpc Network Competition: Mudanjiang Division

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.