A
Neverending Competitions
/*Test Instructions: give you n-line, judge whether you can start from the starting point, turn back. If you can, "home"; otherwise, "contest"*/#include<cstdio>#include<cstring>#include<string>#include<map>using namespacestd;Const intn=1e5+5;intN,cnt,ans;CharStart[n],s1[n],s2[n];intMain () {scanf ("%d",&N); scanf ("%s", start); for(intI=1, l,len;i<=n;i++) {scanf ("%s", S1); Len=strlen (S1); for(intj=0; j<len;j++){ if(s1[j]=='>') {L=0; for(intk=j+1; k<len;k++) {s2[l++]=S1[k]; } S2[l]=' /'; S1[j-1]=' /'; Break; } } if(!STRCMP (START,S1)) ans++; if(!STRCMP (START,S2)) ans--; } if(ans>0) puts ("Contest"); ElsePuts"Home"); return 0;}
B
Code Obfuscation
/*Test instructions: give you a string, change each character, and determine whether all the precursors of the character are also modified*/#include<cstdio>#include<string>#include<iostream>using namespacestd;BOOLmark[ -];intMain () {strings; CIN>>s; for(intI=0; s[i];i++) {Mark[s[i]-'a']=1; for(intj=0; J<= (s[i]-'a'); J + +){ if(!Mark[j]) {Puts ("NO"); return 0; }}} puts ("YES"); return 0;}
C
Table Tennis Game 2
/*Test instructions: Two people play table tennis, hit the K points to complete a bureau ask the most can complete how many innings*/#include<cstdio>using namespacestd;intMain () {intk,a,b; scanf ("%d%d%d",&k,&a,&b); if((a<k&&b%k) | | (b<k&&a%k)) Puts"-1"); Elseprintf"%d\n", a/k+b/k); return 0;}
D
Artsem and Saunders
/*Test Instructions: (math problem) known: F (x)->f (y), N Satisfied: G (H (x)) =x{x∈[m]}, H (g (x)) =f (x) {X∈[n]}. For: M, G (1..N), H (1..M)*/#include<cstdio>using namespaceStd;inlineintRead () {intx=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}Const intn=1e6+5;intN,m,f[n],g[n],h[n];intMain () {n=read (); for(intI=1; i<=n;i++) f[i]=read (); for(intI=1; i<=n;i++)if(F[i]!=i&&f[f[i]]!=f[i]) {Puts ("-1");return 0;} for(intI=1; i<=n;i++){ if(!G[f[i]]) {h[++m]=F[i]; G[f[i]]=m; } G[i]=G[f[i]]; } printf ("%d\n", M); for(intI=1; i<=n;i++) printf ("%d", G[i]);p Utchar ('\ n'); for(intI=1; i<=m;i++) printf ("%d", H[i]);p Utchar ('\ n'); return 0;}
E
Tree Folding
F
Souvenirs
G
Math, Math everywhere
Codeforces Round #397 by Kaspersky Lab and Barcelona bootcamp (div. 1 + div. 2 combined)