Codeforces Beta Round #12 (Div 2 Only)

简介: 点击打开链接 A #include#include#include#includeusing namespace std;char str[3][3];bool isOk(){ for(int i = 0 ; ...

点击打开链接


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])   
             return false; 
       }
    }
    return true;
}

int main(){
    while(gets(str[0])){
        for(int i = 1 ; i < 3 ; i++) 
           gets(str[i]);
        printf("%s\n" , isOk() ? "YES" : "NO");
    }
    return 0;
}


B

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


int main(){
    const int MAXN = 1000;
    bool ans;
    char nStr[MAXN] , mStr[MAXN];
    while(gets(nStr)){
        gets(mStr);
        int len = strlen(nStr);
        sort(nStr , nStr+len);
        int pos = 0;
        for(int i = 0 ; i < len ; i++){
           if(nStr[i] != '0'){
              pos = i;
              break;
           }
        }
        swap(nStr[pos] , nStr[0]);
        printf("%s\n" , !strcmp(nStr , mStr) ? "OK" : "WRONG_ANSWER");
    }
    return 0;
}


C

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

const int N = 110;
map<string , int>mp;
int n , m , pos , num[N] , price[N];

bool cmp(int a , int b){
    return a > b;
}

int main(){
    char str[N];
    while(scanf("%d%d" , &n , &m) != EOF){
         for(int i = 0 ; i < n ; i++) 
             scanf("%d" , &price[i]); 
         mp.clear();
         pos = 1;
         for(int i = 0 ; i < m ; i++){
             scanf("%s" , str);     
             if(!mp[str]) 
                mp[str] = pos++;
             num[mp[str]]++;
         }
         sort(price , price+n);
         sort(num+1 , num+1+pos , cmp);

         int minPrice , maxPrice;
         minPrice = maxPrice = 0;
         int k = 0;
         for(int i = 1 ; i <= pos ; i++)
             minPrice += price[k++]*num[i]; 
         k = n-1;
         for(int i = 1 ; i <= pos ; i++)
             maxPrice += price[k--]*num[i];
         printf("%d %d\n" , minPrice , maxPrice);
    }
    return 0;
}



E

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

const int MAXN = 1010;
int mat[MAXN][MAXN];

int main(){
    int n;
    while(scanf("%d" , &n) != EOF){
         memset(mat , 0 , sizeof(mat));
         for(int i  = 0 ; i < n-1 ; i++){
             for(int j = 0 ; j < n-1 ; j++) 
                 mat[i][j] = (i+j)%(n-1)+1;
         }
         //替换
         for(int i = 0 ; i < n ; i++){
             mat[i][n-1] = mat[i][i];
             mat[n-1][i] = mat[i][i];
             mat[i][i] = 0; 
         }
         //输出
         for(int i = 0 ; i < n ; i++){
             printf("%d" , mat[i][0]);
             for(int j = 1 ; j < n ; j++)
                 printf(" %d" , mat[i][j]);
             printf("\n");
         }
    }
    return 0;
}




目录
相关文章
|
人工智能 索引
Codeforces Round 806 (Div. 4)
Codeforces Round 806 (Div. 4)A~G
94 0
|
机器学习/深度学习 算法 C++
|
人工智能
Codeforces Beta Round #2 A,B,C
A. Winner time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output ...
1206 0
|
Perl
Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard ...
850 0
Codeforces Beta Round #6 (Div. 2 Only)
点击打开链接 A #include #include #include #include #include using namespace std; int l[4]; int main(){ while(scanf("%d...
776 0
|
SDN
Codeforces Beta Round #4 (Div. 2 Only)
点击打开链接 A #include #include #include #include using namespace std; int main(){ int n; while(scanf("%d" , &n) !=...
856 0