Submission #970300

# Submission time Handle Problem Language Result Execution time Memory
970300 2024-04-26T10:31:58 Z mychecksedad Fountain Parks (IOI21_parks) C++17
5 / 100
96 ms 17764 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n';
#define ll long long int
const int N = 3e5+10;


int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
    build({}, {}, {}, {});
        return 1;
    }
    int n = x.size();
    vector<int> u, v, a, b;


    vector<pair<int, int>> L, R;
    for(int i = 0; i < n; ++i){
        if(x[i] == 2) L.pb({y[i], i}); 
        else R.pb({y[i], i});
    }
    sort(all(L));
    sort(all(R));
    for(int i = 0; i + 1 < L.size(); ++i){
        if(L[i + 1].first - L[i].first > 2){
            return 0;
        }
        u.pb(L[i].second);
        v.pb(L[i + 1].second);
        a.pb(1);
        b.pb(L[i + 1].first + L[i].first>>1);
    }
    for(int i = 0; i + 1 < R.size(); ++i){
        if(R[i + 1].first - R[i].first > 2){
            return 0;
        }
        u.pb(R[i].second);
        v.pb(R[i + 1].second);
        a.pb(5);
        b.pb(R[i + 1].first + R[i].first>>1);
    }

    if(!R.empty() && !L.empty()){
        if(L[0].first > R.back().first) return 0;
        if(R[0].first > L.back().first) return 0;
        if(R[0].first > L[0].first) L.swap(R);
        for(int i = 0; i < R.size(); ++i){
            if(R[i].first == L[0].first){
                u.pb(R[i].second);
                v.pb(L[0].second);
                a.pb(3);
                b.pb(R[i].first);
                break;
            }
        }    
    }



    build(u, v, a, b);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:27:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i + 1 < L.size(); ++i){
      |                    ~~~~~~^~~~~~~~~~
parks.cpp:34:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         b.pb(L[i + 1].first + L[i].first>>1);
parks.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0; i + 1 < R.size(); ++i){
      |                    ~~~~~~^~~~~~~~~~
parks.cpp:43:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |         b.pb(R[i + 1].first + R[i].first>>1);
parks.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int i = 0; i < R.size(); ++i){
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
17 Incorrect 0 ms 348 KB b[2] = 2 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
17 Incorrect 0 ms 348 KB b[2] = 2 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
17 Incorrect 0 ms 548 KB b[0] = 2 is not an odd integer
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
17 Incorrect 96 ms 17764 KB Pair u[50000]=2 @(82816, 2) and v[50000]=3 @(97624, 2) does not form a valid edge (distance != 2)
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 8100 KB Output is correct
10 Correct 5 ms 1292 KB Output is correct
11 Correct 22 ms 4484 KB Output is correct
12 Correct 6 ms 1508 KB Output is correct
13 Correct 7 ms 2004 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 47 ms 8092 KB Output is correct
17 Incorrect 0 ms 348 KB b[2] = 2 is not an odd integer
18 Halted 0 ms 0 KB -