CodeforcesRound #294 (Div.2)

Source: Internet
Author: User
Tags bitset
519AAandBandChess *************************************** * ******** Author: fisty * CreatedTime: 201522821: 12: 09 * FileName:. cpp *************************************** * ******** # includeiostream # includecstring # includequ

519A A and B and Chess /********************************* * *************** Author: fisty * Created Time: 2015/2/28 21:12:09 * File Name:. cpp *************************************** * ********/# include iostream # include cstring # include dequ

519A

A and B and Chess

/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:12:09 * File Name   : A.cpp *********************************************** */#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        #include 
         
          #include 
          
           #include 
           
            #include 
            
             #include 
             
              #include using namespace std;#define Debug(x) cout << #x << " " << x <
              
                P;#define FOR(i, a, b) for(int i = a;i < b; i++)int _white(char c){ int n; switch(c){ case 'Q': n = 9;break; case 'R': n = 5;break; case 'B': n = 3;break; case 'N': n = 3;break; case 'P': n = 1;break; dafault: n = 0;break; } return n;}int _black(char c){ int n; switch(c){ case 'q': n = 9;break; case 'r': n = 5;break; case 'b': n = 3;break; case 'n': n = 3;break; case 'p': n = 1;break; dafault: n = 0;break; } return n;}int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); string s; int white = 0;int black = 0; FOR(i, 0, 8){ cin >> s; for(int j = 0;j < s.length(); j++){ if(s[j] <= 'Z' && s[j] >= 'A'){ white += _white(s[j]); }else if(s[j] <= 'z' && s[j] >= 'a'){ black += _black(s[j]); } } } //Debug(white); //Debug(black); if(white > black){ cout << "White" << endl; }else if(white < black){ cout << "Black" << endl; }else{ cout << "Draw" << endl; } return 0;}
              
             
            
           
          
         
       
      
     
    
   
  
 
519B

A and B and Compilation Errors

Comparison between A and B, and comparison between B and C. Sort all, output the first different number and compare it out.
/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:43:51 * File Name   : 294B.cpp *********************************************** */#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        #include 
         
          #include 
          
           #include 
           
            #include 
            
             #include 
             
              #include using namespace std;#define Debug(x) cout << #x << " " << x <
              
                P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 100100 int a[MAX_N], b[MAX_N], c[MAX_N];int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; Memset(a, 0); Memset(b, 0); Memset(c, 0); FOR(i, 0, n){ cin >> a[i]; } FOR(i, 0, n-1){ cin >> b[i]; } FOR(i, 0, n-2){ cin >> c[i]; } sort(a, a + n); sort(b, b + n-1); sort(c, c + n-2); for(int i = 0;i < n; i++){ if(a[i] != b[i]){ cout << a[i] << endl; break; } } for(int i = 0;i < n-1; i++){ if(b[i] != c[i]){ cout << b[i] << endl; break; } } return 0;}
              
             
            
           
          
         
       
      
     
    
   
  
 


519C

A and B and Team Training

If n> m, take n and take two m to get one,


/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:54:12 * File Name   : 294C.cpp *********************************************** */#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        #include 
         
          #include 
          
           #include 
           
            #include 
            
             #include 
             
              #include using namespace std;#define Debug(x) cout << #x << " " << x <
              
                P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 8000int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int ans = 0; while(n >= 1 && m >= 1 && m + n >= 3){ ans++; if(n > m){ n -= 2; m--; }else{ m -= 2; n--; } } cout << ans << endl; return 0;}
              
             
            
           
          
         
       
      
     
    
   
  
 

519D

A and B and Interesting Substrings

First, maintain the prefix and. mp [I] [v] indicates the prefix ending with character I and the number of times V appears.

According to the requirement of the question, if the median of the characters u and v is zero, the prefix and the two are equal.

/*********************************************** * Author: fisty * Created Time: 2015/2/28 22:46:13 * File Name   : 294D.cpp *********************************************** */#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        #include 
         
          #include 
          
           #include 
           
            #include 
            
             #include 
             
              #include using namespace std;#define Debug(x) cout << #x << " " << x <
              
                P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 100000string s;int a[30];map
               
                 mp[MAX_N];int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); for(int i = 0;i < 26; i++){ cin >> a[i]; } cin >> s; int n = s.length(); LL ans = 0; LL v = 0; for(int i = 0;i < n; i++){ ans += mp[s[i]-'a'][v]; v += a[s[i]-'a']; mp[s[i]-'a'][v]++; } cout << ans << endl; return 0;}
               
              
             
            
           
          
         
       
      
     
    
   
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.