# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
846149 |
2023-09-07T11:51:10 Z |
vjudge1 |
ČVENK (COI15_cvenk) |
C++17 |
|
54 ms |
3612 KB |
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
signed main() {
//ios_base::sync_with_stdio(false);
//cin.tie();
int n; cin >> n;
vector<pair<int, int>> v(n);
for (auto& i: v) cin >> i.x >> i.y;
vector<pair<int, int>> vc(v);
vector<pair<int, int>> path1;
vector<pair<int, int>> path2;
for (int i = 1; i < 40; i++){
path1.push_back(v[0]);
v[0].x -= (v[0].x)%(1<<i);
v[0].y -= (v[0].y)%(1<<i);
}
for (int i = 1; i < 40; i++){
path2.push_back(v[1]);
v[1].x -= (v[1].x)%(1<<i);
v[1].y -= (v[1].y)%(1<<i);
}
int ans = 1e16;
/*
for (auto& i: path1){
cout << i.x << ' ' << i.y << endl;
}
cout << endl;
for (auto& i: path2){
cout << i.x << ' ' << i.y << endl;
}
*/
for (int i = 0; i < path1.size(); i++){
for (int j = 0; j < path2.size(); j++){
if (path1[i] == path2[j]) {
pair<int, int> point = path1[i];
ans = min(ans, abs(point.x - vc[0].x) + abs(point.x - vc[1].x) + abs(point.y - vc[0].y) + abs(point.y - vc[1].y));
}
else if (path1[i].x == path2[j].x){
pair<int, int> point = make_pair(path1[i].x, min(path1[i].y, path2[j].y));
ans = min(ans, abs(point.x - vc[0].x) + abs(point.x - vc[1].x) + abs(point.y - vc[0].y) + abs(point.y - vc[1].y));
}
else if (path1[i].y == path2[j].y){
pair<int, int> point = make_pair(min(path1[i].x, path2[j].x), path1[i].y);
ans = min(ans, abs(point.x - vc[0].x) + abs(point.x - vc[1].x) + abs(point.y - vc[0].y) + abs(point.y - vc[1].y));
}
}
}
cout << ans << endl;
}
Compilation message
cvenk.cpp: In function 'int main()':
cvenk.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i = 0; i < path1.size(); i++){
| ~~^~~~~~~~~~~~~~
cvenk.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for (int j = 0; j < path2.size(); j++){
| ~~^~~~~~~~~~~~~~
# |
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 |
28 ms |
3612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
3524 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |