Submission #927008

# Submission time Handle Problem Language Result Execution time Memory
927008 2024-02-14T06:34:25 Z irmuun Spiral (BOI16_spiral) C++17
15 / 100
0 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,q;
    cin>>n>>q;
    while(q--){
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        ll mx=max(abs(x1),abs(y1));
        if(mx==0){
            cout<<1<<"\n";
            continue;
        }
        ll x=(mx*2+1)*(mx*2+1),ans;
        if(y1==-mx){
            ans=x-(mx-x1);
        }
        else if(x1==-mx){
            ans=x-2*mx-(y1+mx);
        }
        else if(y1==mx){
            ans=x-4*mx-(x1+mx);
        }
        else{
            ans=x-6*mx-(mx-y1);
        }
        const ll mod=1e9+7;
        cout<<ans%mod<<"\n";
    }
}
# 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 Correct 0 ms 348 KB Output is correct
# 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 0 ms 348 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 -