Educational Codeforces Round 26 ABC题
2017-08-06 12:31
405 查看
我太弱了这场比赛只做了三道题,atcoder beginer不能AK,我还有什么用
T1
woc,竟然WA了一次
#include<iostream>
#include<cstdio>
using namespace std;
int n,ans,cnt;
char ch[505];
int main(){
scanf("%d\n", &n);
for( int i = 0; i < n; i++ ) ch[i] = getchar();
for( int i = 0; i < n; i++ ){
if( ch[i] >= 'A' && ch[i] <= 'Z' ) cnt++, ans = max(ans,cnt);
if( ch[i] == ' ' ) cnt = 0;
}
printf("%d", ans);
return 0;
}
T2
水题中的战斗机啊,打了我50行,都可以打道线段树了,或者是我想复杂了
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,a1; bool mark[205];
char ch[105][105];
bool work1(){
mark[ch[1][0]] = 1; a1 = ch[1][0];
if( a1 != 'R' && a1 != 'B' && a1 != 'G' )return 0;
for( int i = 1; i <= n/3; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1+n/3][0]; if( mark[a1] ) return 0;
mark[ch[1+n/3][0]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int i = n/3+1; i <= 2*n/3; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1+2*n/3][0]; if( mark[a1] ) return 0;
mark[ch[1+2*n/3][0]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int i = 2*n/3+1; i <= n; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
memset(mark,0,sizeof(mark));
return 1;
}
bool work2(){
mark[ch[1][0]] = 1; a1 = ch[1][0];
if( a1 != 'R' && a1 != 'B' && a1 != 'G' )return 0;
for( int j = 0; j < m/3; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1][m/3]; if( mark[a1] ) return 0;
mark[ch[1][m/3]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int j = m/3; j < 2*m/3; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1][2*m/3]; if( mark[a1] ) return 0;
mark[ch[1][2*m/3]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int j = 2*m/3; j < m; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
memset(mark,0,sizeof(mark));
return 1;
}
int main(){
scanf("%d%d", &n, &m);
if( n % 3 && m % 3 ){ puts("NO"); return 0; }
for( int i = 1; i <= n; i++ ) scanf("%s", ch[i]);
if( n % 3 == 0 && work1() ){ puts("YES"); return 0; }
if( m % 3 == 0 && work2() ){ puts("YES"); return 0; }
puts("NO");
return 0;
}T3
n^2暴搜
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,a,b,ans;
int x[105],y[105];
bool judge( int i, int j ){
if( x[i]+x[j] <= a && y[i] <= b && y[j] <= b ) return 1;
if( x[i]+x[j] <= b && y[i] <= a && y[j] <= a ) return 1;
if( x[i]+y[j] <= a && y[i] <= b && x[j] <= b ) return 1;
if( x[i]+y[j] <= b && y[i] <= a && x[j] <= a ) return 1;
if( y[i]+x[j] <= a && x[i] <= b && y[j] <= b ) return 1;
if( y[i]+x[j] <= b && x[i] <= a && y[j] <= a ) return 1;
if( y[i]+y[j] <= a && x[i] <= b && x[j] <= b ) return 1;
if( y[i]+y[j] <= b && x[i] <= a && x[j] <= a ) return 1;
return 0;
}
int main(){
scanf("%d%d%d", &n, &a, &b);
for( int i = 1; i <= n; i++ ) scanf("%d%d", &x[i], &y[i]);
for( int i = 1; i <= n; i++ )
for( int j = 1; j <= n; j++ )
if( judge(i,j) && i != j ) ans = max(x[i]*y[i]+x[j]*y[j],ans);
printf("%d\n", ans);
return 0;
}我是黑名我自豪
T1
woc,竟然WA了一次
#include<iostream>
#include<cstdio>
using namespace std;
int n,ans,cnt;
char ch[505];
int main(){
scanf("%d\n", &n);
for( int i = 0; i < n; i++ ) ch[i] = getchar();
for( int i = 0; i < n; i++ ){
if( ch[i] >= 'A' && ch[i] <= 'Z' ) cnt++, ans = max(ans,cnt);
if( ch[i] == ' ' ) cnt = 0;
}
printf("%d", ans);
return 0;
}
T2
水题中的战斗机啊,打了我50行,都可以打道线段树了,或者是我想复杂了
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,a1; bool mark[205];
char ch[105][105];
bool work1(){
mark[ch[1][0]] = 1; a1 = ch[1][0];
if( a1 != 'R' && a1 != 'B' && a1 != 'G' )return 0;
for( int i = 1; i <= n/3; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1+n/3][0]; if( mark[a1] ) return 0;
mark[ch[1+n/3][0]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int i = n/3+1; i <= 2*n/3; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1+2*n/3][0]; if( mark[a1] ) return 0;
mark[ch[1+2*n/3][0]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int i = 2*n/3+1; i <= n; i++ )
for( int j = 0; j < m; j++ )
if( ch[i][j] != a1 ) return 0;
memset(mark,0,sizeof(mark));
return 1;
}
bool work2(){
mark[ch[1][0]] = 1; a1 = ch[1][0];
if( a1 != 'R' && a1 != 'B' && a1 != 'G' )return 0;
for( int j = 0; j < m/3; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1][m/3]; if( mark[a1] ) return 0;
mark[ch[1][m/3]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int j = m/3; j < 2*m/3; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
a1 = ch[1][2*m/3]; if( mark[a1] ) return 0;
mark[ch[1][2*m/3]] = 1;
if( a1 != 'R' && a1 != 'B' && a1 != 'G' ) return 0;
for( int j = 2*m/3; j < m; j++ )
for( int i = 1; i <= n; i++ )
if( ch[i][j] != a1 ) return 0;
memset(mark,0,sizeof(mark));
return 1;
}
int main(){
scanf("%d%d", &n, &m);
if( n % 3 && m % 3 ){ puts("NO"); return 0; }
for( int i = 1; i <= n; i++ ) scanf("%s", ch[i]);
if( n % 3 == 0 && work1() ){ puts("YES"); return 0; }
if( m % 3 == 0 && work2() ){ puts("YES"); return 0; }
puts("NO");
return 0;
}T3
n^2暴搜
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,a,b,ans;
int x[105],y[105];
bool judge( int i, int j ){
if( x[i]+x[j] <= a && y[i] <= b && y[j] <= b ) return 1;
if( x[i]+x[j] <= b && y[i] <= a && y[j] <= a ) return 1;
if( x[i]+y[j] <= a && y[i] <= b && x[j] <= b ) return 1;
if( x[i]+y[j] <= b && y[i] <= a && x[j] <= a ) return 1;
if( y[i]+x[j] <= a && x[i] <= b && y[j] <= b ) return 1;
if( y[i]+x[j] <= b && x[i] <= a && y[j] <= a ) return 1;
if( y[i]+y[j] <= a && x[i] <= b && x[j] <= b ) return 1;
if( y[i]+y[j] <= b && x[i] <= a && x[j] <= a ) return 1;
return 0;
}
int main(){
scanf("%d%d%d", &n, &a, &b);
for( int i = 1; i <= n; i++ ) scanf("%d%d", &x[i], &y[i]);
for( int i = 1; i <= n; i++ )
for( int j = 1; j <= n; j++ )
if( judge(i,j) && i != j ) ans = max(x[i]*y[i]+x[j]*y[j],ans);
printf("%d\n", ans);
return 0;
}我是黑名我自豪
相关文章推荐
- Educational Codeforces Round 26
- Educational Codeforces Round 27 (ABC)
- Educational Codeforces Round 26 B - Flag of Berland【思维】
- Educational Codeforces Round 26 C - Two Seals【略带贪心+思维】好题
- 平常水题 Educational Codeforces Round 26 C (错误总结)
- Educational Codeforces Round 26 D (dp好题)
- Educational Codeforces Round 26 E. Vasya's Function(数论)
- Educational Codeforces Round 26 C. Two Seals
- cf Educational Codeforces Round 26 E. Vasya's Function
- Educational Codeforces Round 26 F. Prefix Sums 二分,组合数
- Educational Codeforces Round 26:C. Two Seals
- Educational Codeforces Round 26 D. Round Subset 滚动数组优化DP
- Educational Codeforces Round 26-D-Round Subset(背包DP)
- Educational Codeforces Round 26-E-Vasya's Function(思维)
- 【动态规划】【滚动数组】Educational Codeforces Round 26 D. Round Subset
- Educational Codeforces Round 26 D dp
- Educational Codeforces Round 26 [ D. Round Subset ] [ E. Vasya's Function ] [ F. Prefix Sums ]
- Educational Codeforces Round 26 A B C 三道水题 - - D 动态规划
- Educational Codeforces Round 26
- Educational Codeforces Round 26总结