Submission #1050543

# Submission time Handle Problem Language Result Execution time Memory
1050543 2024-08-09T10:41:53 Z amine_aroua Fountain Parks (IOI21_parks) C++17
5 / 100
228 ms 44700 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<bool> vis;
void dfs(int i)
{
    if(vis[i])
        return;
    vis[i] = 1;
    for(auto j : adj[i])
    {
        dfs(j);
    }
}
void add_edge(int u , int v)
{
    adj[u].push_back(v);
    adj[v].push_back(u);
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    int n= (int)x.size();
    adj.assign(n , {});
    vis.assign(n , 0);
    vector<int> u , v , a , b;
    map<pair<int, int> , int> idx;
    
    for(int i = 0 ; i <n ; i++)
    {
        idx[{x[i] , y[i]}] = i;
    }
    for(int i = 0 ; i < n ;i++)
    {
        if(idx.count({x[i] + 2 , y[i]}))
        {
            u.push_back(i);
            v.push_back(idx[{x[i] + 2 , y[i]}]);
            a.push_back(x[i] + 1);
            b.push_back(y[i]);
        }
        if(idx.count({x[i] , y[i] + 2}))
        {
            u.push_back(i);
            v.push_back(idx[{x[i] , y[i] + 2}]);
            b.push_back(y[i] + 1);
            if(x[i] == 2)
            {
                a.push_back(x[i] - 1);
            }
            else
            {
                a.push_back(x[i] + 1);
            }
        }
    }
    for(int i = 0 ; i < (int)u.size() ; i++)
    {
        add_edge(u[i] , v[i]);
    }
    dfs(0);
    for(int i = 0 ; i < n ; i++)
    {
        if(!vis[i])
        {
            return 0;
        }
    }
    build(u , v , a , b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
17 Incorrect 0 ms 348 KB b[0] = 4 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
17 Incorrect 0 ms 348 KB b[0] = 4 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
17 Incorrect 0 ms 348 KB b[1] = 2 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
17 Incorrect 228 ms 44700 KB b[0] = 100002 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 88 ms 21952 KB Output is correct
10 Correct 6 ms 2648 KB Output is correct
11 Correct 34 ms 12088 KB Output is correct
12 Correct 9 ms 3928 KB Output is correct
13 Correct 22 ms 8172 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 97 ms 20716 KB Output is correct
17 Incorrect 0 ms 348 KB b[0] = 4 is not an odd integer
18 Halted 0 ms 0 KB -