Submission #772059

# Submission time Handle Problem Language Result Execution time Memory
772059 2023-07-03T15:03:15 Z davitmarg Circle selection (APIO18_circle_selection) C++17
23 / 100
1316 ms 55296 KB
/*
DavitMarg
In pr honky-tonk,
Down in Mexico
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <random>
#include <chrono>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair    
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 500005;

#define circle pair<pair<LL, LL>, pair<LL, int>>
#define X first.first
#define Y first.second
#define R second.first
#define I second.second

int n;
circle p[N];
map<pair<LL, LL>, vector<circle>> g;
int ans[N];

bool intersect(circle a, circle b)
{
    LL dx = a.X - b.X;
    LL dy = a.Y - b.Y;
    return (dx * dx) + (dy * dy) <= (a.R + b.R) * (a.R + b.R);
}

void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i].X >> p[i].Y >> p[i].R;
        p[i].X += mod;
        p[i].Y += mod;
        p[i].I = i;
    }

    for (int i = 1; i <= n; i++)
        g[MP(p[i].X / p[i].R, p[i].Y / p[i].R)].push_back(p[i]);



    for (int i = 1; i <= n; i++)
    {
        if (ans[i])
            continue;
        LL x = p[i].X / p[i].R;
        LL y = p[i].Y / p[i].R;

        for(int kx = x - 2; kx <= x + 2; kx++)
            for (int ky = y - 2; ky <= y + 2; ky++)
            {
                if (g.find(MP(kx, ky)) == g.end())
                    continue;
                vector<circle>& c = g[MP(kx, ky)];
                for (int j = 0; j < c.size(); j++)
                {
                    if (ans[c[j].I])
                        continue;
                    if(intersect(p[i], c[j]))
                        ans[c[j].I] = i;
                }
            }

    }

    for (int i = 1; i <= n; i++)
        cout << ans[i] << " ";
    cout << endl;

}

int main()
{
    fastIO;
    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

/*

3
1 1 2
2 2 2
10 10 2


*/

Compilation message

circle_selection.cpp: In function 'void solve()':
circle_selection.cpp:82:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<long long int, long long int>, std::pair<long long int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |                 for (int j = 0; j < c.size(); j++)
      |                                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 23724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1316 ms 50352 KB Output is correct
2 Correct 987 ms 55288 KB Output is correct
3 Correct 337 ms 38056 KB Output is correct
4 Correct 908 ms 55296 KB Output is correct
5 Correct 987 ms 55236 KB Output is correct
6 Correct 218 ms 34780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -