Submission #1095611

# Submission time Handle Problem Language Result Execution time Memory
1095611 2024-10-02T17:23:30 Z huyngodzz Circle selection (APIO18_circle_selection) C++14
0 / 100
1916 ms 350556 KB
    ///huynhocute123///
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define pb push_back
#define pi M_PI
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = b; i >= a; --i)
#define ALL(v) v.begin(),v.end()
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
//random_device rd;
//mt19937 rng(rd());
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
#define int long long
const int maxN = 1e6+ 9 ;
const int  modd = 1e9 + 7;
const int base = 2309;
const int MAX = 1e9+9;
void minimize(int &u, int v){
    if(v < u) u = v;
}
void maximize(int &u, int v){
    if(v > u) u = v;
}
int n, k, t, m, res, ans[maxN];
int l, r;
bool vis[maxN];
int dx[] ={-1 , 0 , 1, -1, 0 , 1, -1, 0 ,-1 };
int dy[] ={-1, -1, -1, 0, 0 ,0 ,1, 1, 1 };
vector<int> e[maxN];
pii a[maxN],Na[maxN];
int R;
map<pii, unordered_set<int>>f;
bool cut(pii a ,pii b){
    int d1 = a.F - b.F;
    int d2 = a.S - b.S;
    if(d1* d1 + d2 * d2 > 4 * R * R)return 0;
    return 1;

}

void solve(){
    cin >> n ;

    FOR(i, 1, n){
        int tmp;
        cin >> a[i].F >> a[i].S >> tmp;
        if(i > 2  && tmp != R)return;
        R = tmp;
//        cout << a[i].F << " ";
        Na[i]= { a[i].F / (2*R) , a[i].S /(2*R) };
        f[Na[i]].insert(i);
    }

    FOR(i, 1, n){
        if(ans[i])continue;
        int X = Na[i].F , Y = Na[i].S;
        FOR(ix, 0 , 8 ){
            int x = X + dx[ix];
            int y= Y + dy[ix];
            vector<int> era;
            for(auto x : f[{x, y}] ){
                if(ans[x] || !cut(a[i], a[x] ))continue;
                ans[x] =i;
                era.pb(x);
            }
            for(auto x : era)f[{X ,Y}].erase(x);
            era.clear();
        }
    }
    for(int i =1; i <= n ;i++)cout << ans[i] << " ";

}
signed main(){
//    freopen("name.inp","r",stdin);
//    freopen("name.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    inp("task.inp");
    t = 1;
   // cin >> t;
    while( t-- )solve();

}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
circle_selection.cpp:85:5: note: in expansion of macro 'inp'
   85 |     inp("task.inp");
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 10 ms 23900 KB Output is correct
3 Incorrect 9 ms 23900 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 23900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 23900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1916 ms 350556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 10 ms 23900 KB Output is correct
3 Incorrect 9 ms 23900 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 10 ms 23900 KB Output is correct
3 Incorrect 9 ms 23900 KB Output isn't correct
4 Halted 0 ms 0 KB -