Submission #1022439

# Submission time Handle Problem Language Result Execution time Memory
1022439 2024-07-13T13:56:30 Z edogawa_something Fountain Parks (IOI21_parks) C++17
0 / 100
14 ms 7636 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define pb push_back
#define F first 
#define S second 
#define all(v) v.begin(),v.end()
const ll M=2e5+10;
vii adj[M];
bool vis[M];
void dfs(ll x){
    if(vis[x])
    return;
    vis[x]=1;
    for(auto it:adj[x]){
        dfs(it);
    }
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    vector<pair<int,int>>f,m,b;
    for(int i=0;i<x.size();i++){
        if(x[i]==2){
            f.pb({y[i],i});
        }
        else
        b.pb({y[i],i});
    }
    vector<int>e1,e2,ax,ay;
    for(int i=0;i<ll(f.size())-1;i++){
        if(f[i+1].F-f[i].F==2){
        e1.pb(f[i].S);
        e2.pb(f[i+1].S);
        ax.pb(1);
        ay.pb(f[i].F+1);
        }
    }
    for(int i=0;i<ll(b.size())-1;i++){
        if(b[i+1].F-b[i].F==2){
        e1.pb(b[i].S);
        e2.pb(b[i+1].S);
        ax.pb(5);
        ay.pb(b[i].F+1);
        }
    }
    ll i=0,j=0;
    while(1){
        if(i==f.size()||j==b.size())
        break;
        if(f[i].F==b[j].F){
            e1.pb(f[i].S),e2.pb(b[j].S);
            ax.pb(3),ay.pb(f[i].S-1);
            i++,j++;
        }
        if(f[i].F<b[j].F){
            i++;
        }
        if(b[j].F<f[i].F){
            j++;
        }
    }
    for(int i=0;i<e1.size();i++)
    adj[e1[i]].pb(e2[i]),adj[e2[i]].pb(e1[i]);
    dfs(0);
    for(int i=0;i<x.size();i++){
        if(!vis[i])
        return 0;
    }
    build(e1,e2,ax,ay);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
parks.cpp:50:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         if(i==f.size()||j==b.size())
      |            ~^~~~~~~~~~
parks.cpp:50:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         if(i==f.size()||j==b.size())
      |                         ~^~~~~~~~~~
parks.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<e1.size();i++)
      |                 ~^~~~~~~~~~
parks.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4924 KB Output is correct
9 Incorrect 14 ms 7636 KB Solution announced impossible, but it is possible.
10 Halted 0 ms 0 KB -