Submission #1004557

# Submission time Handle Problem Language Result Execution time Memory
1004557 2024-06-21T09:48:23 Z vjudge1 Horses (IOI15_horses) C++17
17 / 100
1500 ms 12192 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, int X[], int Y[]){
    n = N;
    x.resize(N);
    y.resize(N);
    ll ke = 0;
    for(int i =0; i < n; i++){
        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]};
    }
    
    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, int 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, int 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, int*, int*)':
horses.cpp:35:8: warning: unused variable 'final' [-Wunused-variable]
   35 |     ll final = 0;
      |        ^~~~~
horses.cpp:39:27: warning: unused variable 'prev' [-Wunused-variable]
   39 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:40:28: warning: unused variable 'cl' [-Wunused-variable]
   40 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
horses.cpp: In function 'long long int updateX(int, int)':
horses.cpp:87:9: warning: unused variable 'final' [-Wunused-variable]
   87 |      ll final = 0;
      |         ^~~~~
horses.cpp:91:27: warning: unused variable 'prev' [-Wunused-variable]
   91 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:92:28: warning: unused variable 'cl' [-Wunused-variable]
   92 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
horses.cpp: In function 'long long int updateY(int, int)':
horses.cpp:137:9: warning: unused variable 'final' [-Wunused-variable]
  137 |      ll final = 0;
      |         ^~~~~
horses.cpp:141:27: warning: unused variable 'prev' [-Wunused-variable]
  141 |     ll cnt = 0, left = 0, prev =1;
      |                           ^~~~
horses.cpp:142:28: warning: unused variable 'cl' [-Wunused-variable]
  142 |     ll ccnt = 0, cleft= 0, cl=0;
      |                            ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1527 ms 12192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 364 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -