Submission #1244497

#TimeUsernameProblemLanguageResultExecution timeMemory
1244497AlperenT_Mosaic (IOI24_mosaic)C++20
8 / 100
114 ms82364 KiB
#include "mosaic.h"

#include <vector>
#include <bits/stdc++.h> 
#pragma GCC optimize("O3,unroll-loops") 
#pragma GCC target("avx2") 
#define pb push_back
#define F first
#define pii pair<int,int> 
#define all(a) a.begin(),a.end()
#define S second 
#define sz(a) (int)a.size()
#define rep(i , a , b) for(int i = (a) ; i <= (b) ; i++)
#define per(i , a , b) for(int i = (a) ; i >= (b) ; i--)
#define ld double
#define ll long long 
using namespace std ;
const int maxn = 1e6   + 100  , sq = 20 , inf = 1e9 , mod = 998244353;
vector <ll>   a[maxn] , s[maxn] ;
ll fen[maxn]  ,n  ,b[maxn];
int ch(int x, int y){
  if(x+y==0)return 1; 
  return 0 ;
}
void upd(int x, int w){
  x++;
  while(x <= 2*n+3){
    fen[x] += w;
    x += x&-x ;
  }
}
ll que(int x){
  ll ans = 0;
  x++;
  while(x){
    ans += fen[x] ;
    x -= x&-x ;
  }
  return ans; 
}
vector <int> vec[maxn] ; 
ll sm[maxn]; 
std::vector<long long> mosaic(std::vector<int> X, std::vector<int> Y,std::vector<int> T, std::vector<int> B,std::vector<int> L, std::vector<int> R) {
  n = sz(X) ;
  vector <ll> C ;
  rep(i , 0 , sz(T)-1){
    if(T[i] == 0)T[i]++;
    if(L[i] == 0)L[i]++;
    ll s = B[i]-T[i]+1 , y =R[i]-L[i]+1;
    if(s < 0 || y < 0){
      C.pb(0);
      continue ;
    }
    if(s*y%2==0){
      C.pb(s*y/2) ;
    }else{
      if((B[i]+R[i])%2 == 0){
        C.pb(s*y/2+1);
      }else{
        C.pb(s*y/2) ;
      }
    }
  }
  
  return C;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...