# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68915 |
2018-08-19T08:52:51 Z |
Abelyan |
Spiral (BOI16_spiral) |
C++17 |
|
4 ms |
592 KB |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
#include <climits>
#include <cstdio>
using namespace std;
typedef long long ll;
ll dist(int x, int y, int xx, int yy) {
return abs(xx - x) + abs(yy - y);
}
const ll MOD = 1000000007;
int main() {
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(false);
ll n;
int m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y >> x >> y;
if (x == 0 && y == 0) {
cout << 1 << endl;
continue;
}
int k = max(abs(x), abs(y));
if (abs(x) >= abs(y) && x<0 || abs(y)>=abs(x) && y < 0) {
ll ans = ((ll)2 * (ll)k + (ll)1)*((ll)2 * (ll)k + (ll)1) - dist(k, -k, x, y);
cout << ans%MOD << endl;
}
else {
ll ans = ((ll)2 * ((ll)k-(ll)1) + (ll)1)*((ll)2 * ((ll)k - (ll)1) + (ll)1) + dist(k, -k, x, y);
//cout << dist(k, -k, x, y) << endl;
cout << ans%MOD << endl;
}
}
system("pause");
return 0;
}
Compilation message
spiral.cpp: In function 'int main()':
spiral.cpp:34:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (abs(x) >= abs(y) && x<0 || abs(y)>=abs(x) && y < 0) {
~~~~~~~~~~~~~~~~~^~~~~~
spiral.cpp:45:8: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
system("pause");
~~~~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
592 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |