Task: | Spiraali |
Sender: | masuman |
Submission time: | 2021-10-07 00:09:31 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 15 |
#2 | ACCEPTED | 20 |
#3 | ACCEPTED | 65 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
#3 | ACCEPTED | 0.01 s | 3 | details |
Compiler report
input/code.cpp: In function 'll ring(ll, ll, ll)': input/code.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ input/code.cpp: In function 'll runningNumber(ll, ll, ll)': input/code.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
Code
#include <bits/stdc++.h> //g++ -std=c++11 -O2 -Wall _____ -o test using namespace std; using ll = long long; ll r(ll y, ll x, ll n, vector<ll> xx){ return max(abs(xx[0]-y), abs(xx[1]-x)); } ll ring(ll y, ll x, ll n){ vector<ll> nw = {n/2, n/2}; vector<ll> ne = {n/2, (n/2)+1}; vector<ll> se = {(n/2)+1,(n/2)+1}; vector<ll> sw = {(n/2)+1,n/2}; if ((x <= n/2) && (y <= n/2)){ return r(y,x,n, nw); } if ((x > n/2) && (y <= n/2)){ return r(y,x,n, ne); } if ((x <= n/2) && (y > n/2)){ return r(y,x,n, sw); } if ((x > n/2) && (y > n/2)){ return r(y,x,n, se); } } vector<ll> ringCount(ll y, ll x, ll n){ ll yNew = y - ((n/2)-1-ring(y,x,n)); ll xNew = x - ((n/2)-1-ring(y,x,n)); vector<ll> result = {yNew, xNew}; return result; } ll runningNumber(ll y, ll x, ll p){ p = (p+1)*2; if (y == p && x == 1){ return p; } if (y == p && x == p){ return (2*p - 1); } if (y==1 && x==1){ return 1; } if (y==1 && x==p){ return (3*p-2); } if(y==1){ return (4*p-2-x); } if(y==p){ return(x+p-1); } if(x==1){ return y; } if(x==p){ return (3*p-1-y); } } ll s(ll n,ll p){ return (4*p*(n-p)); } ll f(ll y,ll x,ll n){ vector<ll> k = ringCount(y,x,n); ll g = ring(y,x,n); ll p = runningNumber(k[0], k[1], g); ll d = (n/2)-g-1; ll e = s(n,d); return e+p; } int main(){ ll t; ll n; cin >> n >> t; ll x, y; for(ll i = 1; i <= t; i++){ cin >> y >> x; cout << f(y,x,n) << "\n"; } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
10 100 1 1 1 2 1 3 1 4 ... |
correct output |
---|
1 36 35 34 33 ... |
user output |
---|
1 36 35 34 33 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 371 263 915 322 946 880 53 738 ... |
correct output |
---|
773533 312166 206053 200080 593922 ... |
user output |
---|
773533 312166 206053 200080 593922 ... Truncated |
Test 3
Group: 3
Verdict: ACCEPTED
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 93689788375037 ... Truncated |