Submission #459271

#TimeUsernameProblemLanguageResultExecution timeMemory
459271hhhhauraTriangles (CEOI18_tri)C++14
100 / 100
28 ms2876 KiB
#define wiwihorz #pragma GCC optimize("Ofast") #pragma loop-opt(on) #include <bits/stdc++.h> #include "trilib.h" #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define all(x) x.begin(), x.end() #define ceil(a, b) ((a + b - 1) / (b)) #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define int long long int #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a) void kout() {cerr << endl;} void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L;} template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif namespace solver { vector<int> v[2], hull; void solve() { int n = get_n(); v[0].push_back(1); v[1].push_back(2); rep(i, 3, n) v[is_clockwise(2, 1, i)].push_back(i); rep(i, 0, 1) sort(v[i].begin() + 1, v[i].end(), [](int a, int b) { return is_clockwise(1, b, a);}); rep(tp, 0, 1) { for(auto i : v[tp]) { while(hull.size() > 1 && is_clockwise( hull[hull.size() - 1], i, hull[hull.size() - 2])) hull.pop_back(); hull.push_back(i); } } int ft = 0, bk = hull.size() - 1; while(true) { bool done = 1; while(is_clockwise(hull[bk], hull[ft], hull[bk - 1])) { done = 0, bk--; } while(is_clockwise(hull[ft], hull[ft + 1], hull[bk])) { done = 0, ft++; } if(done) break; } give_answer(bk - ft + 1); return; } }; using namespace solver; signed main() { ios::sync_with_stdio(false), cin.tie(0); solve(); return 0; }

Compilation message (stderr)

tri.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    3 | #pragma loop-opt(on)
      | 
tri.cpp:26:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   26 | void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
tri.cpp:26:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   26 | void vprint(auto L, auto R) { while(L < R)cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...