Submission #1004467

# Submission time Handle Problem Language Result Execution time Memory
1004467 2024-06-21T09:15:39 Z vjudge1 Horses (IOI15_horses) C++17
17 / 100
1500 ms 8260 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 ans = 0;
    ll have = 1;
    ll cnt = 0, left = 0;
    ll 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];
        if(hold >=mod){
            ccnt++;
        }
    
        if(ccnt> cnt){
            cnt = ccnt+cl;
            left = hold;
        }
        else if(ccnt==cnt && hold> left){
            cnt = ccnt+cl;
            left = hold;
        }
      
        
         
   }
   return left;

}


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

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

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:28:8: warning: unused variable 'ans' [-Wunused-variable]
   28 |     ll ans = 0;
      |        ^~~
horses.cpp:31:8: warning: unused variable 'prev' [-Wunused-variable]
   31 |     ll prev =1;
      |        ^~~~
horses.cpp:32:18: warning: unused variable 'cleft' [-Wunused-variable]
   32 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
horses.cpp: In function 'long long int updateX(int, int)':
horses.cpp:71:8: warning: unused variable 'final' [-Wunused-variable]
   71 |     ll final = 0;
      |        ^~~~~
horses.cpp:74:8: warning: unused variable 'ans' [-Wunused-variable]
   74 |     ll ans = 0;
      |        ^~~
horses.cpp:77:8: warning: unused variable 'prev' [-Wunused-variable]
   77 |     ll prev =1;
      |        ^~~~
horses.cpp:78:18: warning: unused variable 'cleft' [-Wunused-variable]
   78 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
horses.cpp: In function 'long long int updateY(int, int)':
horses.cpp:114:8: warning: unused variable 'final' [-Wunused-variable]
  114 |     ll final = 0;
      |        ^~~~~
horses.cpp:117:8: warning: unused variable 'ans' [-Wunused-variable]
  117 |     ll ans = 0;
      |        ^~~
horses.cpp:120:8: warning: unused variable 'prev' [-Wunused-variable]
  120 |     ll prev =1;
      |        ^~~~
horses.cpp:121:18: warning: unused variable 'cleft' [-Wunused-variable]
  121 |     ll ccnt = 0, cleft= 0, cl=0;
      |                  ^~~~~
# 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 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 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 348 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 344 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
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 1593 ms 8260 KB Time limit exceeded
2 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 344 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 348 KB Output is correct
15 Correct 1 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 1 ms 600 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 344 KB Output is correct
19 Correct 1 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 -