QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50155#868. Friendship CirclesHongzyWA 20ms3720kbC++3.2kb2022-09-24 19:24:032022-09-24 19:24:03

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-24 19:24:03]
  • Judged
  • Verdict: WA
  • Time: 20ms
  • Memory: 3720kb
  • [2022-09-24 19:24:03]
  • Submitted

answer

#include <bits/stdc++.h>
#define LOG(FMT...) fprintf(stderr, FMT);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef long double db;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
mt19937 mt(std::chrono::system_clock::now().time_since_epoch().count());
uniform_int_distribution<ll> ran(0, 1ll << 62);
void ucin() { ios::sync_with_stdio(0); cin.tie(0); }
// uniform_real_distribution<double> dbran;
template<class T> inline void chkmax(T &x, const T &y) { if(x < y) x = y; }
template<class T> inline void chkmin(T &x, const T &y) { if(x > y) x = y; }
inline ll sqr(ll x) { return x * x; }
inline ll cub(ll x) { return x * x * x; }

const int N = 4e5 + 10;
const int mod = 1e9 + 7;
int n;

const db eps = 1e-100;
#define lt(x, y) ((x) < (y) - eps)
#define gt(x, y) ((x) > (y) + eps)
#define leq(x, y) ((x) <= (y) + eps)
#define geq(x, y) ((x) >= (y) - eps)
#define eq(x, y) (leq(x, y) && geq(x, y))
#define cross(u, v, w) ((v - u).det(w - u))
struct point {
  db x, y; int id;
  // void in() { scanf("%lf%lf", &x, &y); }
  // void out() { printf("(%.2f, %.2f)\n", x, y); }
  void in_int() { int a, b; scanf("%d%d", &a, &b); x = a; y = b; }
  db norm() { return sqrt(x * x + y * y); }
  db norm2() { return x * x + y * y; }
  point operator + (point b) { return (point) {x + b.x, y + b.y}; }
  point operator - (point b) { return (point) {x - b.x, y - b.y}; }
  point operator - () const { return (point) {-x, -y}; }
  db operator * (point b) { return x * b.x + y * b.y; }
  point operator * (db b) { return (point) {x * b, y * b}; }
  point operator / (db b) { return (point) {x / b, y / b}; }
  db det(point b) { return x * b.y - y * b.x; }
  bool operator < (point b) const { return lt(x, b.x) || (leq(x, b.x) && lt(y, b.y)); }
  bool operator == (point b) { return eq(x, b.x) && eq(y, b.y); }
} a[N];
void ConvexHull(vector<point> &ps, vector<point> &qs) {
  int n = ps.size();
  if(n <= 1) { qs = ps; return ; }
  sort(ps.begin(), ps.end());
  qs.resize(2 * n); int r = 0;
  rep(i, 0, n - 1) {
    while(r >= 2 && leq(cross(qs[r - 2], qs[r - 1], ps[i]), 0)) r --;
    qs[r ++] = ps[i];
  }
  int t = r;
  per(i, n - 2, 0) {
    while(r >= t + 1 && leq(cross(qs[r - 2], qs[r - 1], ps[i]), 0)) r --;
    qs[r ++] = ps[i];
  }
  qs.resize(r-1);
}
int main() {
  int test;
  scanf("%d", &test);
  rep(T, 1, test) {
    scanf("%d", &n);
    rep(i, 1, n) {
      a[i].in_int();
    }
    if(n == 2) {
      printf("1 1\n");
      continue ;
    }
    a[1].id = 1;
    rep(i, 2, n) {
      db z = (a[i] - a[1]).norm2();
      a[i] = a[1] + (a[i] - a[1]) / z;
      a[i].id = i;
    }
    // printf("%.3f\n", (a[4]-a[3]).det(a[3]-a[2]));
    vector<point> ps, qs;
    rep(i, 1, n) ps.pb(a[i]);
    ConvexHull(ps, qs);
    vector<int> ans;
    for(int i = 0; i < int(qs.size()); i ++)
      if(qs[i].id != 1) ans.pb(qs[i].id-1);
    sort(ans.begin(), ans.end());
    printf("%d", int(ans.size()));
    for(int x : ans)
      printf(" %d", x);
    printf("\n");
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3720kb

input:

2
4
1 0
3 1
3 -2
7 0
5
0 0
-2 -1
2 2
-2 10
-1 11

output:

2 1 2
3 1 2 3

result:

ok 7 numbers

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 3672kb

input:

10000
10
132243110 -894263225
-965927366 756806080
-563126858 -401644076
-528090722 -199265042
-184232391 -184423675
-346777300 -583114791
624815460 788278140
543172921 980159251
-143672624 674688477
-393343296 525780596
9
64745555 827730910
-665070184 -152609349
-905275127 -345568169
-949821348 -84...

output:

3 4 5 6
4 1 4 6 8
1 1
3 1 2 3
2 2 5
2 1 3
6 1 2 3 4 5 6
5 1 2 3 4 9
4 1 2 3 4
6 1 2 3 4 5 9
2 1 2
3 1 4 6
5 2 4 5 6 7
4 1 2 4 5
3 1 2 3
4 1 2 3 6
3 1 6 8
1 1
2 1 2
5 1 3 4 6 7
5 1 2 4 5 6
3 2 3 4
4 1 3 4 7
4 1 3 7 9
3 3 4 5
4 3 4 6 8
5 1 3 4 6 7
3 1 2 3
2 2 3
3 2 5 6
3 1 2 3
3 2 3 4
4 2 5 6 8
3 1 4 ...

result:

wrong answer 5th numbers differ - expected: '5', found: '4'