UCF Local Programming Contest 2016 Official Game

A. Solving Problems

1.Majestic 10

Meaning of the questions: a few larger than ten, most of the water, feeling

AC Code:

#include<iostream>
#define N 10
using namespace std;
int main()
{
int n,i,a[N];
cin>>n;
while(n--){
int count=0;
for(i=1;i<=3;i++){
cin>>a[i];
if(a[i]>=10)count++;
}
for(i=1;i<3;i++){
cout<<a[i]<<" ";
}
cout<<a[i]<<endl;
if(count==0)
cout<<"zilch"<<endl;
else if(count==1)
cout<<"double"<<endl;
else if(count==2)
cout<<"double-double"<<endl;
else cout<<"triple-double"<<endl;
cout<<"\n";
}
}

II. Replenishment

1.Phoneme Palindromes

Meaning of the questions: palindrome string similar, but somewhat different letters will be equivalent to the same

I did not understand the solution to a problem, drawing on the idea of ​​students, with disjoint-set to do

AC Code:

#include <the iostream>
#include <String>
#include <cstdio>
the using namespace STD;
#define N 100001
int Father [N];
int Find (int X) {
the while (! Father [X] = X) // they are their root node
x = father [x]; // not continue to look for, find boss
return X;
}
void Merge (A int, int B) {
int A1 = find (A); // root node is found, to find the boss
int Find = B1 (B);
IF (! A1 = B1) // different boss, to identify the main
Father [A1] = B1;
}
int main ()
{
int T, Case1 = 0;
CIN >> T;
the while (T- -) {
the printf ( "% # the Test Case D: \ n-", Case1 ++);
int W;
CIN >> W;
for (int I = 'A'; I <= 'Z'; I ++) {
Father [ i] = i; // each own head
}
the while (W -) {
char Q,p;
Q >> >> P CIN;
Merge (Q, P);
}
int m;
CIN >> m;
for (int I =. 1; I <= m; I ++) {
int. 1 = R & lt;
String S;
CIN >> S;
int s.size D = ();
IF (D ==. 1) {S COUT << << "" << "YES" << endl; Continue;}
the else {
for (int J = 0; J < D / 2; J ++) {
! IF (Father [S [J]] = Father [S [DJ-. 1]]) {// this judgment is because the same on both sides, value is the same, is not the same time, to see whether a set the initial value is assigned ,, significance
R & lt = 0;
COUT S << << "" << "NO" << endl;
BREAK;
}
}
IF (R & lt ==. 1) COUT S << << "" << "YES" << endl;
}
}
COUT << endl;
}
}

Guess you like

Origin www.cnblogs.com/1324a/p/12607039.html