Submission #1051851

# Submission time Handle Problem Language Result Execution time Memory
1051851 2024-08-10T10:12:46 Z MarwenElarbi Fountain Parks (IOI21_parks) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
const int nax=2e5+5;
set<pair<int,int>> mp;
map<pair<int,int>,int> cor;
set<pair<int,int>> vis;
bool check(pair<int,int> a){
    if(!mp.count({a.fi-2,a.se})&&!mp.count({a.fi+2,a.se})&&!mp.count({a.fi,a.se-2})&&!mp.count({a.fi,a.se+2})) return false;
    return true; 
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    int n=y.size();
    for (int i = 0; i < n; ++i)
    {
        mp.insert({x[i],y[i]});
        cor[{x[i],y[i]}]=i;
    }
    bool test=true;
    for(auto i:mp){
        if(!check(i)){
            test=false;
            break;
        }
        if(mp.count({i.fi+2,i.se})){
            pair<int,int> cur={i.fi+1,i.se-1};
            if(vis.count(cur)) cur.se+=2;
            vis.insert(cur);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi+2,i.se}]);
        }
        if(mp.count({i.fi,i.se+2})){
            pair<int,int> cur={i.fi-1,i.se+1};
            if(vis.count(cur)) cur.fi+=2;
            vis.insert(cur);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi,i.se+2}]);
        }
    }
    if(!test) return 0;
    build(u, v, a, b);
    assert(u.size()>n-1);
    return 1;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from parks.cpp:1:
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:54:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |     assert(u.size()>n-1);
      |            ~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -