QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#511825#9175. Geometry Hackingucup-team008#AC ✓1ms3832kbC++175.7kb2024-08-10 11:41:282024-08-10 11:41:29

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 11:41:29]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3832kb
  • [2024-08-10 11:41:28]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
typedef vector<int> vi;
#define f first
#define s second
#define derr if(0) cerr
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << flush;
// END NO SAD

template<class Fun>
class y_combinator_result {
  Fun fun_;
public:
  template<class T>
  explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

  template<class ...Args>
  decltype(auto) operator()(Args &&...args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

template<class T>
bool updmin(T& a, T b) {
  if(b < a) {
    a = b;
    return true;
  }
  return false;
}
template<class T>
bool updmax(T& a, T b) {
  if(b > a) {
    a = b;
    return true;
  }
  return false;
}
typedef int64_t ll;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};
typedef Point<ll> P;

template<class T>
T polygonArea2(vector<Point<T>>& v) {
	T a = v.back().cross(v[0]);
	rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
	return a;
}

template<class P>
int segmentIntersection(const P& s1, const P& e1,
		const P& s2, const P& e2, P& r1, P& r2) {
	if (e1==s1) {
		if (e2==s2) {
			if (e1==e2) { r1 = e1; return 1; } //all equal
			else return 0; //different point segments
		} else return segmentIntersection(s2,e2,s1,e1,r1,r2);//swap
	}
	//segment directions and separation
	P v1 = e1-s1, v2 = e2-s2, d = s2-s1;
	auto a = v1.cross(v2), a1 = v1.cross(d), a2 = v2.cross(d);
	if (a == 0) { //if parallel
		auto b1=s1.dot(v1), c1=e1.dot(v1),
		     b2=s2.dot(v1), c2=e2.dot(v1);
		if (a1 || a2 || max(b1,min(b2,c2))>min(c1,max(b2,c2)))
			return 0;
		r1 = min(b2,c2)<b1 ? s1 : (b2<c2 ? s2 : e2);
		r2 = max(b2,c2)>c1 ? e1 : (b2>c2 ? s2 : e2);
		return 2-(r1==r2);
	}
	if (a < 0) { a = -a; a1 = -a1; a2 = -a2; }
	if (0<a1 || a<-a1 || 0<a2 || a<-a2)
		return 0;
	r1 = s1-v1*a2/a;
	return 1;
}

void solve() {
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    vector<P> poly;
    poly.eb(-2, -1);
    poly.eb(1, 0);
    poly.eb(2, -i);
    poly.eb(1, 1);
    /*
    int ans = 0;
    for(auto p: poly) {
      ans += p.y == 0 && p.x >= 0;
    }
    for(int a = 0; a < sz(poly); a++) {
      int b = (a+1)%sz(poly);
      P sanity;
      ans += segmentIntersection(poly[a], poly[b], P(0, 0), P(1e9, 0), sanity, sanity);
    }
    assert(ans % 2 == 0);
    assert(polygonArea2(poly) == 4);
    */
    cout << sz(poly) << "\n";
    for(auto p: poly) cout << p.x << " " << p.y << "\n";
  }
}

// what would chika do
// are there edge cases (N=1?)
// are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// integer overflow?
// DS reset properly between test cases
// are you doing geometry in floating points
// are you not using modint when you should

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

2

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1

result:

ok Everything ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

1

output:

4
-2 -1
1 0
2 -1
1 1

result:

ok Everything ok

Test #3:

score: 0
Accepted
time: 1ms
memory: 3488kb

input:

1000

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1
4
-2 -1
1 0
2 -3
1 1
4
-2 -1
1 0
2 -4
1 1
4
-2 -1
1 0
2 -5
1 1
4
-2 -1
1 0
2 -6
1 1
4
-2 -1
1 0
2 -7
1 1
4
-2 -1
1 0
2 -8
1 1
4
-2 -1
1 0
2 -9
1 1
4
-2 -1
1 0
2 -10
1 1
4
-2 -1
1 0
2 -11
1 1
4
-2 -1
1 0
2 -12
1 1
4
-2 -1
1 0
2 -13
1 1
4
-2 -1
1 0
2 -14
1 1
4...

result:

ok Everything ok

Test #4:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

500

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1
4
-2 -1
1 0
2 -3
1 1
4
-2 -1
1 0
2 -4
1 1
4
-2 -1
1 0
2 -5
1 1
4
-2 -1
1 0
2 -6
1 1
4
-2 -1
1 0
2 -7
1 1
4
-2 -1
1 0
2 -8
1 1
4
-2 -1
1 0
2 -9
1 1
4
-2 -1
1 0
2 -10
1 1
4
-2 -1
1 0
2 -11
1 1
4
-2 -1
1 0
2 -12
1 1
4
-2 -1
1 0
2 -13
1 1
4
-2 -1
1 0
2 -14
1 1
4...

result:

ok Everything ok

Test #5:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

399

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1
4
-2 -1
1 0
2 -3
1 1
4
-2 -1
1 0
2 -4
1 1
4
-2 -1
1 0
2 -5
1 1
4
-2 -1
1 0
2 -6
1 1
4
-2 -1
1 0
2 -7
1 1
4
-2 -1
1 0
2 -8
1 1
4
-2 -1
1 0
2 -9
1 1
4
-2 -1
1 0
2 -10
1 1
4
-2 -1
1 0
2 -11
1 1
4
-2 -1
1 0
2 -12
1 1
4
-2 -1
1 0
2 -13
1 1
4
-2 -1
1 0
2 -14
1 1
4...

result:

ok Everything ok

Test #6:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

420

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1
4
-2 -1
1 0
2 -3
1 1
4
-2 -1
1 0
2 -4
1 1
4
-2 -1
1 0
2 -5
1 1
4
-2 -1
1 0
2 -6
1 1
4
-2 -1
1 0
2 -7
1 1
4
-2 -1
1 0
2 -8
1 1
4
-2 -1
1 0
2 -9
1 1
4
-2 -1
1 0
2 -10
1 1
4
-2 -1
1 0
2 -11
1 1
4
-2 -1
1 0
2 -12
1 1
4
-2 -1
1 0
2 -13
1 1
4
-2 -1
1 0
2 -14
1 1
4...

result:

ok Everything ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

69

output:

4
-2 -1
1 0
2 -1
1 1
4
-2 -1
1 0
2 -2
1 1
4
-2 -1
1 0
2 -3
1 1
4
-2 -1
1 0
2 -4
1 1
4
-2 -1
1 0
2 -5
1 1
4
-2 -1
1 0
2 -6
1 1
4
-2 -1
1 0
2 -7
1 1
4
-2 -1
1 0
2 -8
1 1
4
-2 -1
1 0
2 -9
1 1
4
-2 -1
1 0
2 -10
1 1
4
-2 -1
1 0
2 -11
1 1
4
-2 -1
1 0
2 -12
1 1
4
-2 -1
1 0
2 -13
1 1
4
-2 -1
1 0
2 -14
1 1
4...

result:

ok Everything ok

Extra Test:

score: 0
Extra Test Passed