Submission #1165323

#TimeUsernameProblemLanguageResultExecution timeMemory
11653238pete8Triangles (CEOI18_tri)C++20
Compilation error
0 ms0 KiB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
#include "trilib.h"
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
#define double long double
using namespace std;
const int mod=998244353,mxn=2e3+5,inf=1e18,minf=-1e18,lg=30;
//#undef int
int n,k,m,x,q;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
bool cmp(int a,int b){
	return (is_clockwise(1,a,b));
}
bool cmp2(int a,int b){
	return (is_clockwise(1,a,b));
}
int32_t main(){
	fastio
	int n=get_n();
	vector<int>L,R;
	for(int i=3;i<=n;i++){
		if(is_clockwise(1,2,i))R.pb(i);
		else L.pb(i);
	}
	sort(all(R),cmp);
	sort(all(L),cmp2);
	L.pb(2);
	L.pb(1);
	vector<int>st={1,2};
	vector<int>del(n+1);
	for(int j=0;j<2;j++){
		for(auto i:R){
			if(del[i])continue;
			if(st[st.size()-2]==i||st[st.size()-1]==i||st[s.size()-2]==st.back()){
				continue;
			}
			while(st.size()>2&&is_clockwise(st[st.size()-2],i,st.back())){
				del[st.back()]=1,st.pop_back();
			}
			st.pb(i);
		}
		st.pb(1);

		for(auto i:L){
			if(del[i])continue;
			if(st[st.size()-2]==i||st[st.size()-1]==i||st[s.size()-2]==st.back()){
				continue;
			}
			while(st.size()>2&&is_clockwise(st[st.size()-2],i,st.back()))del[st.back()]=1,st.pop_back();
			st.pb(i);
		}
		st.pb(2);
	}

	int c=0;
	for(int i=1;i<=n;i++)if(del[i]==0)c++;
	give_answer(c);
}

/*
6 
1 1
4 3
2 2
1 4
5 1
3 2

7
8 6
1 1
2 5 	
4 10
9 5
3 6
2 5
*/

Compilation message (stderr)

tri.cpp:33:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   33 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
tri.cpp:40:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   40 | void setIO(string name){
      |                       ^
tri.cpp:45:21: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   45 | bool cmp(int a,int b){
      |                     ^
tri.cpp:48:22: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   48 | bool cmp2(int a,int b){
      |                      ^
tri.cpp:51:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   51 | int32_t main(){
      |              ^
tri.cpp: In function 'int32_t main()':
tri.cpp:22:11: error: 'second' was not declared in this scope
   22 | #define s second
      |           ^~~~~~
tri.cpp:68:71: note: in expansion of macro 's'
   68 |                         if(st[st.size()-2]==i||st[st.size()-1]==i||st[s.size()-2]==st.back()){
      |                                                                       ^
tri.cpp:22:11: error: 'second' was not declared in this scope
   22 | #define s second
      |           ^~~~~~
tri.cpp:80:71: note: in expansion of macro 's'
   80 |                         if(st[st.size()-2]==i||st[st.size()-1]==i||st[s.size()-2]==st.back()){
      |                                                                       ^
tri.cpp: In function 'void setIO(std::string)':
tri.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tri.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~