Contest1808 - 2019年我能变强组队训练赛第二场
ANGLES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<bits/stdc++.h> using namespace std; int main() { int n,a,b,c; scanf ( "%d" ,&n); while (n--) { scanf ( "%d%d%d" ,&a,&b,&c); if (a+b+c==180) { printf ( "%d %d %d Seems OK\n" ,a,b,c); } else { printf ( "%d %d %d Check\n" ,a,b,c); } } } |
GOLF CROQUET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #include<bits/stdc++.h> #define po set<node>::iterator using namespace std; const int maxn = 1e5 + 10; int n, cnts, cntt, len, sw, tw; char s[maxn], t[maxn], o[maxn]; int main() { //freopen("1.txt", "r", stdin); char ch; while (ch = getchar ()) { if (ch == '\n' ) break ; s[++cnts] = ch; } while (ch = getchar ()) { if (ch == '\n' ) break ; t[++cntt] = ch; } int flag=0; scanf ( "%d" , &len); scanf ( "%s" , o + 1); for ( int i = 1; i <= len; ++i) { if (i % 2) { if (o[i] == 'S' ) continue ; if (o[i] == 'H' ) { sw++; if (sw == 7){ if (i<len)flag=1; goto ed; } } if (o[i] == 'D' ) { if (sw + 2 > 7) { sw=7; if (i<len)flag=1; goto ed; } else if (sw + 2 == 7) { sw += 2; if (i<len)flag=1; goto ed; } else { sw += 2; //cout<<"debug i="<<i<<' '<<sw<<endl; } } if (o[i] == 'O' ) { tw++; if (tw == 7) { if (i<len)flag=1; goto ed; } } } else { if (o[i] == 'S' ) continue ; if (o[i] == 'H' ) { tw++; if (tw == 7){ //if(i<len)flag=1; goto ed; } } if (o[i] == 'D' ) { if (tw + 2 > 7) { tw=7; //if(i<len)flag=1; goto ed; } else if (tw + 2 == 7) { tw += 2; //if(i<len)flag=1; goto ed; } else { tw += 2; } } //O H H O H //S S D S D if (o[i] == 'O' ) { sw++; if (sw == 7) { if (i<len)flag=1; goto ed; } } } } ed:; int ss = 1, tt = 1; while (ss <= cnts) { printf ( "%c" , s[ss++]); } printf ( " " ); printf ( "%d " , sw); while (tt <= cntt) { printf ( "%c" , t[tt++]); } printf ( " " ); printf ( "%d" , tw); printf ( ". " ); if (sw != tw && max(sw, tw) != 7) { if (sw > tw) { ss = 1; while (ss <= cnts) { printf ( "%c" , s[ss++]); } } else if (sw < tw) { tt = 1; while (tt <= cntt) { printf ( "%c" , t[tt++]); } } printf ( " is winning.\n" ); } else if (sw != tw && max(sw, tw) == 7) { if (sw > tw) { ss = 1; while (ss <= cnts) { printf ( "%c" , s[ss++]); } } else if (sw < tw) { tt = 1; while (tt <= cntt) { printf ( "%c" , t[tt++]); } } printf ( " has won.\n" ); } else { printf ( "All square.\n" ); } return 0; } |
BYTE ME!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #include<bits/stdc++.h> #define po set<node>::iterator using namespace std; const int maxn=1e5+10; int n; int c[16][10]; int o[10],q[16],s[16]; int main(){ //freopen("1.txt","r",stdin); scanf ( "%d" ,&n); for ( int i=1;i<=n;++i){ for ( int j=1;j<=8;++j){ scanf ( "%d" ,&c[i][j]); } for ( int j=1;j<=8;++j){ if (c[i][j])q[i]++; } q[i]=q[i]%2; } int cnt=0; for ( int i=1;i<=8;++i){ scanf ( "%d" ,o+i); if (o[i])cnt++; } cnt=cnt%2; int cnt1=0,cnt2=0; for ( int i=1;i<=n;++i){ if (q[i]) cnt1++; else cnt2++; } if (cnt1==1){ printf ( "Even\n" ); cnt=1; } else { printf ( "Odd\n" ); cnt=0; } for ( int i=1;i<=n;++i){ if (q[i]==cnt){ printf ( "Byte %d is broken\n" ,i); break ; } } for ( int i=1;i<=8;++i){ for ( int j=1;j<=n;++j){ if (c[j][i]){ s[i]++; } } } for ( int i=1;i<=8;++i){ if (o[i]){ s[i]++; } s[i]=s[i]%2; } int ss=0,tt=0,ids,idt; for ( int i=1;i<=8;++i){ if (s[i]){ ss++; ids=i; } else { tt++; idt=i; } } if (ss==1){ printf ( "Bit %d is broken\n" ,ids); } else { printf ( "Bit %d is broken\n" ,idt); } return 0; } |
TREES
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #include<bits/stdc++.h> using namespace std; struct node { char c; node* lc=NULL; node* rc=NULL; int h,hl,hr; void geths() { if (lc!=NULL) lc->geths(); if (rc!=NULL) rc->geths(); hl= lc==NULL?0:lc->h+(lc->rc==0); hr= rc==NULL?0:rc->h+(rc->lc==0); h=1+hl+hr; } }; void build(node* &root) { char cc; scanf ( " %c" ,&cc); if (cc== '@' ) { return ; } root = new node(); root->c=cc; build(root->lc); build(root->rc); } const int N = 405; char a[N+5][N+5]; void print(node*p, int sx, int sy) { if (p==NULL) return ; int x=sx,y=sy; if (p->lc!=NULL) { for ( int i=1; i<p->lc->hr; i++) { x--; a[x][y]= '|' ; } x--; y++; a[x][y]= '/' ; x--; y++; print(p->lc,x,y); } a[sx][sy]=p->c; x=sx; y=sy; if (p->rc!=NULL) { for ( int i=1; i<p->rc->hl; i++) { x++; a[x][y]= '|' ; } x++; y++; a[x][y]= '\\' ; x++; y++; print(p->rc,x,y); } } int main() { int _,ca=0; scanf ( "%d" ,&_); while (_--) { printf ( "Graph %d\n" ,++ca); memset (a, ' ' , sizeof (a)); node *root; build(root); root->geths(); print(root,root->hl+1,0); for ( int i=1; i<=root->h; i++) { int jend=N; for (; a[i][jend]== ' ' ; jend--); a[i][jend+1]=0; printf ( "%s\n" ,a[i]); } printf ( "\n" ); } return 0; } |
PACKING
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin= new Scanner(System.in); int _=cin.nextInt(); for ( int t=1;t<=_;t++){ int w[]= new int [110]; int v[]= new int [110]; int dp[][]= new int [1100][1100]; int n=cin.nextInt(); int w1=cin.nextInt(); int w2=cin.nextInt(); for ( int i=1;i<=n;i++){ w[i]=cin.nextInt(); } for ( int i=1;i<=n;i++){ v[i]=cin.nextInt(); } for ( int i=1;i<=n;i++){ for ( int j=w1;j>=0;j--){ for ( int k=w2;k>=0;k--){ if (j>=w[i]) dp[j][k]=max(dp[j][k],dp[j-w[i]][k]+v[i]); if (k>=w[i]) dp[j][k]=max(dp[j][k],dp[j][k-w[i]]+v[i]); } } } System.out.println( "Problem " +t+ ": " +dp[w1][w2]); } } static int max( int a, int b){ if (a>b) return a; return b; } } |
DOMINO KKILLING
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #include<bits/stdc++.h> using namespace std; typedef pair< int , int >PII; map<PII, char >m; int ans; void solve( int s, int t, int x, int y, int cnt) { ans=max(ans,cnt); if (s<0||t<0) { return ; } if (m[make_pair(s,t)]== '-' ) { m[make_pair(s,t)]= '.' ; if (y==1) { solve(s,t+1,0,1,cnt+1); } else { if (y==-1) { solve(s,t-1,0,-1,cnt+1); } else { return ; } } } else if (m[make_pair(s,t)]== '|' ) { m[make_pair(s,t)]= '.' ; if (x==1) { solve(s+1,t,1,0,cnt+1); } else { if (x==-1) { solve(s-1,t,-1,0,cnt+1); } else { return ; } } } else if (m[make_pair(s,t)]== '\\' ) { m[make_pair(s,t)]= '.' ; if (x==1&&y==-1||x==1&&y==0||x==0&&y==-1) { solve(s+1,t-1,1,-1,cnt+1); } else if (x==-1&&y==1||x==-1&&y==0||x==0&&y==1) { solve(s-1,t+1,-1,1,cnt+1); } else return ; } else if (m[make_pair(s,t)]== '/' ) { m[make_pair(s,t)]= '.' ; if (x==1&&y==1||(x+y)==1) { solve(s+1,t+1,1,1,cnt+1); } else if (x==-1&&y==-1||(x+y)==-1) { solve(s-1,t-1,-1,-1,cnt+1); } else return ; } else return ; } int main() { ios::sync_with_stdio( false ); cin.tie(0); int n,s,x,y; while (cin>>n>>s>>x>>y) { if (x==0&&y==0&&n==0&&s==0) { break ; } m.clear(); int a,b,S,T; char c; ans=0; for ( int i=0; i<n; i++) { cin>>a>>b>>c; m[make_pair(a,b)]=c; if (i==s) { S=a; T=b; } } solve(S,T,x,y,0); printf ( "%d\n" ,ans); } return 0; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步