Codeforces Round #290 (Div. 2) Issue Report A. B .C.D.

Source: Internet
Author: User
Tags acos

Codeforces Round #290 (Div. 2) Issue Report A. B .C.D.

A-Fox And Snake

Simulation.

The Code is as follows:

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     
      
# Include
      # Include
       
         # Include
        
          Using namespace std; # define LL _ int64 # define pi acos (-1.0) const int mod = 1e9 + 7; const int INF = 0x3f3f3f; const double eqs = 1e-9; int main () {int n, m, I, j; while (scanf ("% d", & n, & m )! = EOF) {for (I = 0; I
         
          
B-Fox And Two Dots

Dfs judgment ring. During the competition, the flag variable defines a global and a flag in the main function. After being adjusted for half an hour, the cause of the error is found... Kneeling...

The Code is as follows:

# Include
           
            
# Include
            
             
# Include
             
              
# Include
              
               
# Include
               
                
# Include
                # Include
                 
                   # Include
                  
                    Using namespace std; # define LL _ int64 # define pi acos (-1.0) const int mod = 1e9 + 7; const int INF = 0x3f3f3f; const double eqs = 1e-9; char s [100] [100]; int vis [100] [100], n, m, d [100] [100], flag; int jx [] = {0, 0, 1,-1}; int jy [] = {1,-1, 0}; void dfs (int x, int y, char c, int ans) {int I, j, a, B; if (flag) return; for (I = 0; I <4; I ++) {a = x + jx [I]; B = y + jy [I]; if (a> = 0 &
                   
                     = 0 & B
                    
                      = 3) {flag = 1; return ;}} if (flag) return ;}int main () {int I, j, ans; while (scanf ("% d", & n, & m )! = EOF) {for (I = 0; I
                     
                      
C-Fox And Names

Topology Sorting bare question .. CF has an issue with the template ..

The Code is as follows:

#include 
                       
                        #include 
                        
                         #include 
                         
                          #include 
                          
                           #include #include 
                           
                            #include 
                            #include 
                             
                              #include 
                              
                               using namespace std;#define LL __int64#define pi acos(-1.0)const int mod=1e9+7;const int INF=0x3f3f3f3f;const double eqs=1e-9;char s[200][200];int a[200], head[200], cnt, d[200], c[200], tot;struct node{ int u, v, next;}edge[100000];void add(int u, int v){ edge[cnt].v=v; edge[cnt].next=head[u]; head[u]=cnt++;}void topo(){ int i, j; queue
                               
                                q; for(i=0;i<26;i++){ if(!d[i]){ q.push(i); } } while(!q.empty()){ int u=q.front(); q.pop(); c[tot++]=u; d[u]--; for(i=head[u];i!=-1;i=edge[i].next){ int v=edge[i].v; if(d[v]!=-1){ d[v]--; if(d[v]==0) q.push(v); } } } if(tot<26) puts("Impossible"); else { for(i=0;i<26;i++){ printf("%c",c[i]+'a'); } }}int main(){ int n, i, j, len1, len2, flag, f; while(scanf("%d",&n)!=EOF){ for(i=0;i
                                
                                 len2){ f=1; break; } } } if(f) puts("Impossible"); else{ tot=0; topo(); } } return 0;}
                                
                               
                              
                             
                           
                          
                         
                        
                       

D-Fox And Jumping

Brute force... It is required that the gcd of the Set be 1 with the least cost. since the data is only 300, there may not be many cases of all gcd, so you can directly save all the gcd and then use brute force DP.

The Code is as follows:

#include 
                       
                        #include 
                        
                         #include 
                         
                          #include 
                          
                           #include #include 
                           
                            #include 
                            #include 
                             
                              #include 
                              
                               using namespace std;#define LL __int64#define pi acos(-1.0)const int mod=1e9+7;const int INF=0x3f3f3f3f;const double eqs=1e-9;map
                               
                                dp;struct node{ LL l, c;}fei[400];LL gcd(LL x, LL y){ return y==0?x:gcd(y,x%y);}int main(){ int n, i, j; scanf("%d",&n); for(i=0;i
                                
                                 ::iterator it; for(i=0;i
                                 
                                  

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.