結果
問題 | No.3078 Very Simple Traveling Salesman Problem |
ユーザー | UMRgurashi |
提出日時 | 2023-04-02 14:39:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,809 bytes |
コンパイル時間 | 2,242 ms |
コンパイル使用メモリ | 203,548 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 23:54:35 |
合計ジャッジ時間 | 3,257 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> #define int long long #define double long double using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define REP(i,n) for(int i=1;i<=n;i++) #define sREP(i,n) for(int i=1;i*i<=n;++i) #define krep(i,k,n) for(int i=(k);i<n+k;i++) #define Krep(i,k,n) for(int i=(k);i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define Rrep(i,n) for(int i=n;i>0;i--) #define frep(i,n) for(auto &x:n) #define LAST(x) x[x.size()-1] #define ALL(x) (x).begin(),(x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x) #define RUD(a,b) (((a)+(b)-1)/(b)) #define sum1_n(n) ((n)*(n+1)/2) #define SUM1n2(n) (n*(2*n+1)*(n+1))/6 #define SUMkn(k,n) (SUM1n(n)-SUM1n(k-1)) #define SZ(x) ((int)(x).size()) #define PB push_back #define Fi first #define Se second #define lower(vec, i) *lower_bound(ALL(vec), i) #define upper(vec, i) *upper_bound(ALL(vec), i) #define lower_count(vec, i) (int)(lower_bound(ALL(vec), i) - (vec).begin()) #define acc(vec) accumulate(ALL(vec),0LL) template<class... T> void in(T&... a) { (cin >> ... >> a); } int ini() { int x; cin >> x; return x; } string ins() { string x; cin >> x; return x; } template <class T> using v = vector<T>; template <class T> using vv = vector<v<T>>; template <class T> using vvv = vector<vv<T>>; using pint = pair<int, int>; using tint = tuple<int, int, int>; using qint = tuple<int, int, int, int>; namespace geometry { using Real = double; const Real EPS = 1e-12; const Real PI = acos(static_cast<Real>(-1)); enum { OUT, ON, IN }; inline int sign(const Real& r) { return r <= -EPS ? -1 : r >= EPS ? 1 : 0; } inline bool equals(const Real& a, const Real& b) { return sign(a - b) == 0; } } namespace geometry { using Point = complex< Real >; istream& operator>>(istream& is, Point& p) { Real a, b; is >> a >> b; p = Point(a, b); return is; } ostream& operator<<(ostream& os, const Point& p) { return os << real(p) << " " << imag(p); } Point operator*(const Point& p, const Real& d) { return Point(real(p) * d, imag(p) * d); } // rotate point p counterclockwise by theta rad Point rotate(Real theta, const Point& p) { return Point(cos(theta) * real(p) - sin(theta) * imag(p), sin(theta) * real(p) + cos(theta) * imag(p)); } Real cross(const Point& a, const Point& b) { return real(a) * imag(b) - imag(a) * real(b); } Real dot(const Point& a, const Point& b) { return real(a) * real(b) + imag(a) * imag(b); } bool compare_x(const Point& a, const Point& b) { return equals(real(a), real(b)) ? imag(a) < imag(b) : real(a) < real(b); } bool compare_y(const Point& a, const Point& b) { return equals(imag(a), imag(b)) ? real(a) < real(b) : imag(a) < imag(b); } using Points = vector< Point >; } namespace geometry { using Polygon = vector< Point >; using Polygons = vector< Polygon >; } namespace geometry { int convex_polygon_contains(const Polygon& Q, const Point& p) { int N = (int)Q.size(); complex<double> x(3.0, 0.0); Point g = (Q[0] + Q[N / 3] + Q[N * 2 / 3]) / x; if (equals(imag(g), imag(p)) && equals(real(g), real(p))) return 2; Point gp = p - g; int l = 0, r = N; while (r - l > 1) { int mid = l + (r-l) / 2; Point gl = Q[l] - g; Point gm = Q[mid] - g; if (cross(gl, gm) > 0) { if (cross(gl, gp) >= 0 && cross(gm, gp) <= 0) r = mid; else l = mid; } else { if (cross(gl, gp) <= 0 && cross(gm, gp) >= 0) l = mid; else r = mid; } } r %= N; Real v = cross(Q[l] - p, Q[r] - p); return sign(v) == 0 ? 1 : sign(v) == -1 ? 0 : 2; } } using namespace geometry; void solve() { int N = ini(); cout << N << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); //cout << fixed << setprecision(14); //cout << setfill('0') << right << setw(4)<< solve(); }