Codeforces Beta Round #6 (Div. 2 Only)

点击打开链接

A

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

int l[4];

int main(){
   while(scanf("%d%d%d%d" , &l[0] , &l[1] , &l[2] , &l[3]) != EOF){
       int s[3];
       int mark = 0;
       for(int i = 0 ; i < 4 ; i++){
          for(int j = i+1 ; j < 4 ; j++){
             for(int k = j+1 ; k < 4 ; k++){
                 s[0] = l[i] , s[1] = l[j] , s[2] = l[k];
                 sort(s , s+3);
                 if(s[2] < s[1]+s[0] && s[2] > s[1]-s[0]){
                   printf("TRIANGLE\n");
                   mark = 1;
                   break;
                 }
             }
             if(mark)
                break;
          }
          if(mark)
             break;
       }
       if(mark)
          continue;
       for(int i = 0 ; i < 4 ; i++){
          for(int j = i+1 ; j < 4 ; j++){
             for(int k = j+1 ; k < 4 ; k++){
                 s[0] = l[i] , s[1] = l[j] , s[2] = l[k];
                 sort(s , s+3);
                 if(s[0] == 0 || s[2] == s[1]+s[0]){
                   printf("SEGMENT\n");
                   mark = 1;
                   break;
                 }
             }
             if(mark)
                break;
          }
          if(mark)
             break;
       }
       if(!mark)
         printf("IMPOSSIBLE\n");
   }
   return 0;
}

B

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;

#define MAXN 110

int n , m;
char c;
int dir[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char maze[MAXN][MAXN];
set<char>s;

int main(){
   while(scanf("%d %d %c" , &n , &m , &c) != EOF){
      for(int i = 0 ; i < n ; i++)
         scanf("%s" , maze[i]);
      s.clear();
      //cout<<c<<endl;
      for(int i = 0 ; i < n ; i++){
         for(int j = 0 ; j < m ; j++){
            //cout<<maze[i][j];
            if(maze[i][j] == c){
              for(int k = 0 ; k < 4 ; k++){
                 int x = i+dir[k][0];
                 int y = j+dir[k][1];
                 if(x < 0 || x >= n || y < 0 || y >= m)
                    continue;
                 if(maze[x][y] != '.' && maze[x][y] != c)
                   s.insert(maze[x][y]);
              }
            }
         }
         //cout<<endl;
      }
      printf("%d\n" , s.size());
   }
   return 0;
}

C

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAXN 100010

int n;
int Time[MAXN];

void solve(){
   int Acnt , Bcnt;
   Acnt = 1 , Bcnt = 1;
   int Asum , Bsum;
   Asum = Time[0] , Bsum = Time[n-1];
   int i , j;
   i = 0 , j = n-1;

   while(i+1 != j){
       if(Asum < Bsum){
         Acnt++;
         i++;
         Asum += Time[i];
       }
       else if(Asum > Bsum){
         Bcnt++;
         j--;
         Bsum += Time[j];
       }
       else{
         Acnt++;
         i++;
         Asum += Time[i];
       }
   }
   printf("%d %d\n" , Acnt , Bcnt);
}

int main(){
   while(scanf("%d" , &n) != EOF){
      for(int i = 0 ; i < n ; i++)
         scanf("%d" , &Time[i]);
      if(n == 1)
         printf("1 0\n");
      else
         solve();
   }
   return 0;
}
时间: 2024-10-24 22:27:30

Codeforces Beta Round #6 (Div. 2 Only)的相关文章

Codeforces Beta Round #9 (Div. 2 Only)

点击打开链接cf#9 A 思路:求gcd然后化简 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int gcd(int a ,int b){ return b == 0 ? a : gcd(b , a%b); } int main(){ int a , b; while(scanf("%d%d"

Codeforces Beta Round #12 (Div 2 Only)

点击打开链接 A #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; char str[3][3]; bool isOk(){ for(int i = 0 ; i < 3 ; i++){ for(int j = 0 ; j < 3 ; j++){ if(str[i][j] != str[2-i][2-j]) r

Codeforces Beta Round #4 (Div. 2 Only)

点击打开链接 A #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; int main(){ int n; while(scanf("%d" , &n) != EOF){ if(n < 4) printf("NO\n"); else{ if(n%2 == 0) prin

Codeforces Beta Round #10

点击打开链接cf#10 A 思路:模拟 分析: 1 题目要求找到总共的电脑的消耗.题目明确指出在n个时间段之内电脑都是属于第一种状态,并且如果不是第一种状态只要移动鼠标或按键盘马上变为第一种状态. 2 题目还指出每一组输入都保证L<R,并且Ri-1<Li.那么我们只要每输入一个就处理一个即可. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>

Codeforces Beta Round #11

点击打开链接 A #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int MAXN = 2010; int n , d; int num[MAXN]; int main(){ while(scanf("%d%d" , &n , &d) != EOF){ for(int i

Codeforces Beta Round #8

点击打开链接 A 思路:正反字符串各自判断一次是否有对应的两个子串 分析: 1 题目给定一个字符串str,然后给定两个不同时间段内看到的子串s1 , s2,判断是哪一种情况. 2 我们知道两个时间段内那么看到的字符串是有间隔的,那么如果我们怎么知道是否是"向前""向后""都有""没有"这四种答案中的哪一种呢?其实我们知道如果给定的两个子串都是给定的字符串str的子串,那么我们就必须正反都判断是否都能按照顺序看到s1 和 s2.

Codeforces Beta Round #3

点击打开链接 A #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<map> using namespace std; #define MAXN 500010 #define N 10 int ans , end; int sx , sy , ex , ey; int vis[N][N]; int dir[8][2] = {{0,1

Codeforces Beta Round #7

点击打开链接 A #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 8 char G[N][N]; int main(){ while(scanf("%s" , G[0]) != EOF){ for(int i = 1 ; i < 8 ; i++) scanf("%

Codeforces Beta Round #1

点击打开链接 A #include<iostream> #include<cstdio> using namespace std; long long n , m , a; int main(){ long long sum; while(cin>>n>>m>>a){ long long x , y; x = n%a == 0 ? n/a : n/a+1; y = m%a == 0 ? m/a : m/a+1; sum = x*y; cout&l