Submission #667576

# Submission time Handle Problem Language Result Execution time Memory
667576 2022-12-01T17:58:46 Z berr Roads (CEOI20_roads) C++17
15 / 100
50 ms 7748 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+37;
//1.st subtask all are vertical
vector<array<int, 2>> a[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n; cin>>n;
    vector<array<int, 2>> node(2*n+1);
    vector<int> x, y;
    map<int, int> cx, cy;
    for(int i=1; i<=n*2; i+=2)
    {
        cin>>node[i][0]>>node[i][1];
        cin>>node[i+1][0]>>node[i+1][1];

        x.push_back(node[i][0]);
        x.push_back(node[i+1][0]);
        y.push_back(node[i][1]);
        y.push_back(node[i+1][1]);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());


    int cnt=1;

    for(auto i: x)
    {
        if(!cx.count(i)) cx[i]=cnt, cnt++;
    }

    cnt=1;

    for(auto i: y)
    {
        if(!cy.count(i)) cy[i]=cnt, cnt++;
    }


    for(int i=1; i<=2*n; i++)
    {
        a[cx[node[i][0]]].push_back({cy[node[i][1]], i});
    }


    for(int i=0; i<N; i++)
    {
        if(a[i].size())
        {
            sort(a[i].begin(), a[i].end());
        }
    }

    vector<array<int, 4>> ans;
    for(int i=1; i<N; i++)
    {
        if(a[i].size()){
        for(int l=1; l<a[i].size()-1; l+=2)
        {
            int v=a[i][l][1];
            int u=a[i][l+1][1];
            ans.push_back({node[v][0], node[v][1], node[u][0], node[u][1]});
        }
        if(!a[i+1].size()) break;


        int v=a[i][0][1];
        int u=a[i+1][0][1];
            ans.push_back({node[v][0], node[v][1], node[u][0], node[u][1]});

    }
    }


   for(int i=0; i<n-1; i++) cout<<ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<" "<<ans[i][3]<<"\n";

}

Compilation message

roads.cpp: In function 'int main()':
roads.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         for(int l=1; l<a[i].size()-1; l+=2)
      |                      ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Failed 1 ms 2644 KB Condition failed: "Volt[i]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2900 KB Output is correct
4 Correct 23 ms 5320 KB Output is correct
5 Correct 49 ms 7716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2900 KB Output is correct
4 Correct 22 ms 5348 KB Output is correct
5 Correct 50 ms 7748 KB Output is correct
6 Failed 2 ms 2644 KB Condition failed: "Volt[i]"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 3 ms 2900 KB Output is correct
4 Correct 31 ms 5300 KB Output is correct
5 Correct 47 ms 7692 KB Output is correct
6 Failed 1 ms 2644 KB Condition failed: "Volt[i]"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 2 ms 2644 KB Condition failed: "Volt[i]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 2 ms 2644 KB Condition failed: "Volt[i]"
2 Halted 0 ms 0 KB -