Submission #1004574

# Submission time Handle Problem Language Result Execution time Memory
1004574 2024-06-21T09:57:48 Z vjudge1 Horses (IOI15_horses) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
#define vi vector<int>

int n ;
vector<pi> x, y;

const int mod = 1e9+7;

ll init(int N, ll X[], ll Y[]){
    n = N;
    x.resize(N);
    y.resize(N);
    ll ke = 0;
    for(int i =0; i < n; i++){
        ke = 0;
        while(X[i]>=mod){
            ke++;
            X[i]%=mod;
        }
        x[i] = {ke, X[i]};
        ke = 0;
        while(Y[i]>=mod){
            ke++;
            Y[i]%=mod;
        }
        y[i] = {ke, Y[i]};
       
    }
    
  //  cout << X[0] *X[1]<<endl;
    ll final = 0;
    
  
    ll have = 1;
    ll cnt = 0, left = 0, prev =1;
    ll ccnt = 0, cleft= 0, cl=0;
    
   for(int i = 1; i <= n; i++){
         ccnt += x[i-1].f;
          have = ((have* x[i-1].s));
        
        
         cleft = 0;
        while(have>=mod){
            cleft++;
            have %=mod;
        }
        ccnt *= cleft;
      
        ll hold = have*y[i-1].s;
         cleft = 0;
        while(hold >=mod){
            hold%=mod;
            cleft++;
        }
    
        if((ccnt*y[i-1].f)*cleft> cnt){
            cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
        else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
             cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
      
        
         
   }
   return left;

}


ll updateX(int pos, ll val){
    
    int he = 0;
    while(val>=mod){
        he++;
        val%=mod;
    }
    x[pos]={he,val};
    
     ll final = 0;
    
  
    ll have = 1;
    ll cnt = 0, left = 0, prev =1;
    ll ccnt = 0, cleft= 0, cl=0;
    
   for(int i = 1; i <= n; i++){
         ccnt += x[i-1].f;
          have = ((have* x[i-1].s));
        
        
         cleft = 0;
        while(have>=mod){
            cleft++;
            have %=mod;
        }
        ccnt *= cleft;
      
        ll hold = have*y[i-1].s;
         cleft = 0;
        while(hold >=mod){
            hold%=mod;
            cleft++;
        }
    
        if((ccnt*y[i-1].f)*cleft> cnt){
            cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
        else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
             cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
      
        
         
   }
   return left;

}

ll updateY(int pos, ll val){
    int he = 0;
    while(val>=mod){
        he++;
        val%=mod;
    }
    y[pos]={he,val};
    
     ll final = 0;
    
  
    ll have = 1;
    ll cnt = 0, left = 0, prev =1;
    ll ccnt = 0, cleft= 0, cl=0;
    
   for(int i = 1; i <= n; i++){
         ccnt += x[i-1].f;
          have = ((have* x[i-1].s));
        
        
         cleft = 0;
        while(have>=mod){
            cleft++;
            have %=mod;
        }
        ccnt *= cleft;
      
        ll hold = have*y[i-1].s;
         cleft = 0;
        while(hold >=mod){
            hold%=mod;
            cleft++;
        }
    
        if((ccnt*y[i-1].f)*cleft> cnt){
            cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
        else if((ccnt*y[i-1].f)*cleft==cnt && hold> left){
             cnt = (ccnt*y[i-1].f)*cleft;
            left = hold;
        }
      
        
         
   }
   return left;
}

Compilation message

horses.cpp: In function 'long long int init(int, long long int*, long long int*)':
horses.cpp:38:8: warning: unused variable 'final' [-Wunused-variable]
   38 |     ll final = 0;
      |        ^~~~~
horses.cpp:42:27: warning: unused variable 'prev' [-Wunused-variable]
   42 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:43:28: warning: unused variable 'cl' [-Wunused-variable]
   43 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
horses.cpp: In function 'long long int updateX(int, long long int)':
horses.cpp:90:9: warning: unused variable 'final' [-Wunused-variable]
   90 |      ll final = 0;
      |         ^~~~~
horses.cpp:94:27: warning: unused variable 'prev' [-Wunused-variable]
   94 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:95:28: warning: unused variable 'cl' [-Wunused-variable]
   95 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
horses.cpp: In function 'long long int updateY(int, long long int)':
horses.cpp:140:9: warning: unused variable 'final' [-Wunused-variable]
  140 |      ll final = 0;
      |         ^~~~~
horses.cpp:144:27: warning: unused variable 'prev' [-Wunused-variable]
  144 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:145:28: warning: unused variable 'cl' [-Wunused-variable]
  145 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
/usr/bin/ld: /tmp/ccPVuSaB.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
/usr/bin/ld: grader.c:(.text.startup+0x113): undefined reference to `updateX(int, int)'
/usr/bin/ld: grader.c:(.text.startup+0x16d): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status