Submission #893695

# Submission time Handle Problem Language Result Execution time Memory
893695 2023-12-27T09:42:27 Z The_Blitz Spiral (BOI16_spiral) C++17
15 / 100
1 ms 348 KB
// TODO -> PONER ALGO AQUI
// amigos y no más
// I'm in the coolest driver high
// += O(logn) ; + = O(n)
 
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define ones(x) __builtin_popcount(x)
#define loga2(x) __builtin_ctzll(x)
#define pos2(x) __builtin_clzll(x)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair <ii, ii> iiii;

const ll mod = 1000000007;
const ll inf = (1LL<<62)-1;


void go(){
  int n,q;
  cin>>n>>q;
  for(int i=1; i<=q;i++){
    long long x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
    // x1==x2 and y1==y2
    long long z = max( abs(x1), abs(y1));
    long long lim = ((z+z+1)*(z+z+1))%mod;  

    // horizontal line
    if(-y1 == z) cout << (mod + mod + lim - (z-x1) ) % mod << "\n";
    else{
      lim -= z; lim -= z; lim+=mod; lim+=mod;
      lim %=mod;
      // vertical line
      if(-x1 == z) cout << (mod + mod + lim - (z+y1) ) % mod << "\n";
      else{
        lim -= z; lim -= z; lim+=mod; lim+=mod;
        lim %=mod;
        // horizontal line
        if(y1 == z)  cout << (mod + mod + lim - (z+x1) ) % mod << "\n";
        else{
          lim -= z; lim -= z; lim+=mod; lim+=mod;
          lim %=mod;
          // vertical line
          if(x1 == z)  cout << (mod + mod + lim - (z-y1) ) % mod << "\n";
        }
      }
    }

  }
} 
    

int main() {
  fastio;
  go();
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -