Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined)

Source: Internet
Author: User
Tags bitset stdin strcmp cmath

Portal: http://codeforces.com/contest/765

A: Give your home name, and n the beginning and end of the ticket, Jinotega start at home, you have to judge according to the beginning and end of these tickets Jinotega is not at home. Direct record the number of times the beginning and end of the home appear, if the equal description Jinotega at home, otherwise not at home.

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<string>#include<stack>#include<map>#include<Set>#include<bitset>#defineX First#defineY Second#defineCLR (U,V); memset (u,v,sizeof (U));#defineIn () freopen ("Data", "R", stdin);#defineOut () Freopen ("ans", "w", stdout);#defineClear (Q); while (! Q.empty ()) Q.pop ();#definePB Push_backusing namespaceStd;typedefLong LongLl;typedef pair<int,int>PII;Const intMAXN = 1e5 +Ten;Const intINF =0x3f3f3f3f;Charstr[ -];Chars[5];intMain () {intN; scanf ("%d", &N); scanf ("%s", s); intAns =0;  for(inti =0; I < n; i++) {scanf ("%s", str); str[3] =' /'; if(strcmp (str, s) = =0) ans++; if(strcmp (str +5, s) = =0) ans--; }    if(ANS) puts ("Contest"); ElsePuts"Home"); return 0;}
View Code

B: This question test instructions I also do not understand, probably give you a string, and then you want to cover in alphabetical order, first cover A, then cover B, cover the first a before you can not encounter B, c......z. I directly recorded the first occurrence of each character position, the resulting sequence if the non-descending output Yes, otherwise output no

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<string>#include<stack>#include<map>#include<Set>#include<bitset>#defineX First#defineY Second#defineCLR (U,V); memset (u,v,sizeof (U));#defineIn () freopen ("Data", "R", stdin);#defineOut () Freopen ("ans", "w", stdout);#defineClear (Q); while (! Q.empty ()) Q.pop ();#definePB Push_backusing namespaceStd;typedefLong LongLl;typedef pair<int,int>PII;Const intMAXN = 1e5 +Ten;Const intINF =0x3f3f3f3f;CharSTR[MAXN];intn[ -];intMain () {CLR (N,0x3f); scanf ("%s", str +1); intlen = strlen (str +1);  for(inti =1; I <= Len; i++)    {        intid = str[i]-'a'; if(N[id] = = INF) N[id] =i; }//for (int i=0;i<26;i++)//printf ("%d\n", N[i]);     for(inti =1; I < -; i++)        if(N[i] < n[i-1]) {puts ("NO"); return 0; } puts ("YES"); return 0;}
View Code

C: Test instructions is there are two people in the game table tennis, table tennis is the K-system (who first reached the K-score who wins), the first person won a total of a, the second person won a total of B, asked them the maximum number of innings (must be a full inning), if not present, then output-1. Relatively easy to think of greed, directly to each game as a 11:0, and then the remainder of the final distribution to any game on the line, so the answer is a/k+b/k, however, this problem has a pit point, that is, if a/k = = 0, then the first person is unable to deal with B%k this part of the, b same, so to special sentence.

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<string>#include<stack>#include<map>#include<Set>#include<bitset>#defineX First#defineY Second#defineCLR (U,V); memset (u,v,sizeof (U));#defineIn () freopen ("Data", "R", stdin);#defineOut () Freopen ("ans", "w", stdout);#defineClear (Q); while (! Q.empty ()) Q.pop ();#definePB Push_backusing namespaceStd;typedefLong LongLl;typedef pair<int,int>PII;Const intMAXN = 1e5 +Ten;Const intINF =0x3f3f3f3f;intMain () {ll k, n, M; CIN>> k >> N >>m; ll ans= n/k + M/K; if(ans = =0) cout <<-1<<Endl; Else    {        if(n/k = =0&& m% k) cout <<-1<<Endl; Else if(m/k = =0&& n k) cout <<-1<<Endl; Elsecout << ans <<Endl; }    return 0;}
View Code

D: Test instructions is giving you a sequence f (x), allowing you to construct a sequence that makes g(H(x))? x for all, and H(g(x))? =? F(x) for all, this problem is a construction problem, I was constructed according to the sample XJB, as for why, I do not know = = (Escape)

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<string>#include<stack>#include<map>#include<Set>#include<bitset>#defineX First#defineY Second#defineCLR (U,V); memset (u,v,sizeof (U));#defineIn () freopen ("Data", "R", stdin);#defineOut () Freopen ("ans", "w", stdout);#defineClear (Q); while (! Q.empty ()) Q.pop ();#definePB Push_backusing namespaceStd;typedefLong LongLl;typedef pair<int,int>PII;Const intMAXN = 1e5 +Ten;Const intINF =0x3f3f3f3f;intF[MAXN], G[MAXN], H[MAXN], ID[MAXN];intMain () {intN; scanf ("%d", &N);  for(inti =1; I <= N; i++) {scanf ("%d", &F[i]); H[f[i]]=F[i]; G[i]=F[i]; }    intCNT =1;  for(inti =1; I <= N; i++)        if(H[i]) {Id[h[i]]=CNT; H[CNT]=H[i]; CNT++; }     for(inti =1; I <= N; i++) G[i]=Id[g[i]];  for(inti =1; I < CNT; i++)        if(G[h[i]]! =i) {puts ("-1"); return 0; }     for(inti =1; I <= N; i++)        if(H[g[i]]! =F[i]) {Puts ("-1"); return 0; } printf ("%d\n", CNT-1);  for(inti =1; I <= N; i++) printf ("%d", G[i]); Puts ("");  for(inti =1; I < CNT; i++) printf ("%d", H[i]); Puts (""); return 0;}
View Code

This is the most pit of C, the first step on the pit I thought in time climbed up, did not think the last or because of write less an else in the final Test hang off, and finally rely on XJB write D title on the blue name, but hang the C question is still very regrettable.

Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined)

Related Article

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.