Submission #1004519

# Submission time Handle Problem Language Result Execution time Memory
1004519 2024-06-21T09:34:50 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 ;
vi x, y;

const int mod = 1e9+7;

ll init(int N, int X[], int Y[]){
    n = N;
    x.resize(N);
    y.resize(N);
    for(int i =0; i < n; i++){
        x[i] = X[i];
        y[i] = Y[i];
    }
    
    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++){
         cl = 0;
         have = ((have* x[i-1]));
         cout << have << "  " << ccnt <<" " << cl <<endl;
        while(have>=mod){
            ccnt++;
            have %=mod;
        }
        while(y[i-1]>=mod){
            cl++;
            y[i-1]%=mod;
        }
        ll hold = have*y[i-1];
    
        while(hold >=mod){
            hold%=mod;
            ccnt++;
        }
    
        if(ccnt*cl> cnt){
            cnt = ccnt*cl;
            left = hold;
        }
        else if((ccnt*cl)==cnt && hold> left){
            cnt = ccnt*cl;
            left = hold;
        }
      
        
         
   }
   return left;

}


ll updateX(int pos, int val){
    
    x[pos]=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++){
         cl = 0;
         have = ((have* x[i-1]));
        
        while(have>=mod){
            ccnt++;
            have %=mod;
        }
        while(y[i-1]>=mod){
            cl++;
            y[i-1]%=mod;
        }
        ll hold = have*y[i-1];
       while(hold >=mod){
            hold%=mod;
            ccnt++;
        }
    
        if(ccnt*cl> cnt){
            cnt = ccnt*cl;
            left = hold;
        }
        else if(ccnt*cl==cnt && hold> left){
            cnt = ccnt*cl;
            left = hold;
        }
   }
   return left;
}

ll updateY(int pos, int val){
     y[pos]=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++){
         cl = 0;
         have = ((have* x[i-1]));
         //cotu << have << endl;
        while(have>=mod){
            ccnt++;
            have %=mod;
        }
        while(y[i-1]>=mod){
            cl++;
            y[i-1]%=mod;
        }
        ll hold = have*y[i-1];
        while(hold >=mod){
            hold%=mod;
            ccnt++;
        }
    
        if(ccnt*cl> cnt){
            cnt = ccnt*cl;
            left = hold;
        }
        else if(ccnt*cl==cnt && hold> left){
            cnt = ccnt*cl;
            left = hold;
        }
      
        
         
   }
   return left;
}


int main(){
    
    int n;
    cin >> n;
    int a[n], b[n];
    for(int& i : a){
        cin >> i;
    }
    for(int &i : b){
        cin >> i;
        
    }
    
    cout << init(n,a,b)<<endl;
    
}


Compilation message

horses.cpp: In function 'long long int init(int, int*, int*)':
horses.cpp:25:8: warning: unused variable 'final' [-Wunused-variable]
   25 |     ll final = 0;
      |        ^~~~~
horses.cpp:29:27: warning: unused variable 'prev' [-Wunused-variable]
   29 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:30:18: warning: unused variable 'cleft' [-Wunused-variable]
   30 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
horses.cpp: In function 'long long int updateX(int, int)':
horses.cpp:72:8: warning: unused variable 'final' [-Wunused-variable]
   72 |     ll final = 0;
      |        ^~~~~
horses.cpp:76:27: warning: unused variable 'prev' [-Wunused-variable]
   76 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:77:18: warning: unused variable 'cleft' [-Wunused-variable]
   77 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
horses.cpp: In function 'long long int updateY(int, int)':
horses.cpp:115:8: warning: unused variable 'final' [-Wunused-variable]
  115 |     ll final = 0;
      |        ^~~~~
horses.cpp:119:27: warning: unused variable 'prev' [-Wunused-variable]
  119 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:120:18: warning: unused variable 'cleft' [-Wunused-variable]
  120 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
horses.cpp: In function 'int main()':
horses.cpp:158:9: warning: declaration of 'n' shadows a global declaration [-Wshadow]
  158 |     int n;
      |         ^
horses.cpp:11:5: note: shadowed declaration is here
   11 | int n ;
      |     ^
/usr/bin/ld: /tmp/ccemjHW7.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCpcwE8.o:horses.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status