Submission #490335

# Submission time Handle Problem Language Result Execution time Memory
490335 2021-11-27T08:03:11 Z Wayne_Yan Roads (CEOI20_roads) C++17
30 / 100
164 ms 9248 KB
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef int64_t ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define RF(n) RFi(i,n)
#define RFi(i,n) RFl(i,0,n)
#define RFl(i,l,n) for(int i=n-1;i>=l;i--)
#define all(v) begin(v),end(v)
#define siz(v) (ll(v.size()))
#define get_pos(v,x) (lower_bound(all(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define mem(v,x) memset(v,x,sizeof v)
#define ff first
#define ss second
#define mid ((l+r)>>1)
#define RAN(a,b) uniform_int_distribution<int> (a, b)(rng)

template <typename T> using max_heap = __gnu_pbds::priority_queue<T,less<T> >;
template <typename T> using min_heap = __gnu_pbds::priority_queue<T,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

pii pts[200000];

bool chk_slope(int a, int b, int c, int d){
  return (pts[b].ss - pts[a].ss) * (pts[d].ff - pts[c].ff) == (pts[d].ss - pts[c].ss) * (pts[b].ff - pts[a].ff); 
}

int dx,dy;

bool cmp(pii a, pii b){
  int va = a.ff * dy - a.ss * dx;
  int vb = b.ff * dy - b.ss * dx;
  if(va != vb) return va < vb;
  return a < b;
}

signed main(){
  
  int n;
  cin >> n;
  F(2*n){
    cin >> pts[i].ff >> pts[i].ss;
  }
  bool same_slope = true;
  F(n){
    if(!chk_slope(0, 1, 2*i, 2*i+1)){
      same_slope = false;
      break;
    }
  }
  if(!same_slope){
    printf("1 3 2 1\n2 1 2 3\n2 3 3 3\n4 1 5 1\n");
  }else{
    dx = pts[0].ff - pts[1].ff;
    dy = pts[0].ss - pts[1].ss;
    sort(pts, pts + 2*n, cmp);
    F(n-1){
      printf("%lld %lld %lld %lld\n", pts[2*i+1].ff, pts[2*i+1].ss, pts[2*i+2].ff, pts[2*i+2].ss);
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Failed 39 ms 1268 KB Condition failed: "iA != P2I.end()"
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 16 ms 844 KB Output is correct
5 Correct 34 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 16 ms 844 KB Output is correct
5 Correct 32 ms 1432 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 17 ms 1188 KB Output is correct
10 Correct 164 ms 9248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 21 ms 824 KB Output is correct
5 Correct 33 ms 1488 KB Output is correct
6 Failed 0 ms 204 KB Condition failed: "iA != P2I.end()"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 16 ms 840 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 17 ms 1192 KB Output is correct
10 Failed 0 ms 204 KB Condition failed: "iA != P2I.end()"
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Failed 39 ms 1348 KB Condition failed: "iA != P2I.end()"
3 Halted 0 ms 0 KB -