답안 #119296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119296 2019-06-21T01:36:03 Z tmwilliamlin168 Printed Circuit Board (CEOI12_circuit) C++14
75 / 100
100 ms 23544 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=1e5;
int n, b[mxN], c[mxN+1], e1[mxN], e2[mxN];
array<ll, 2> a[mxN+1];
vector<int> va[mxN], vr[mxN], vp[mxN], ans;

bool cw(int x, int y, int z) {
	return (a[z][1]-a[x][1])*(a[y][0]-a[x][0])<(a[y][1]-a[x][1])*(a[z][0]-a[x][0]);
}

bool pcmp(const int &i, const int &j) {
	return a[i][1]*a[j][0]<a[j][1]*a[i][0];
}

struct scmp {
	bool operator()(const int &i, const int &j) const {
		if(e1[i]==e1[j])
			return c[e2[i]]<c[e2[j]]?!cw(e1[j], e2[j], e2[i]):cw(e1[i], e2[i], e2[j]);
		return c[e1[i]]<c[e1[j]]?cw(e1[i], e2[i], e1[j]):!cw(e1[j], e2[j], e1[i]);
	}
};
set<int, scmp> s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for(int i=0; i<n; ++i)
		cin >> a[i][0] >> a[i][1];
	a[n]=a[0];
	iota(b, b+n, 0);
	sort(b, b+n, pcmp);
	for(int i=0; i<n; ++i) {
		c[i]=lower_bound(b, b+n, i, pcmp)-b;
		vp[c[i]].push_back(i);
	}
	c[n]=c[0];
	for(int i=0; i<n; ++i) {
		e1[i]=i;
		e2[i]=i+1;
		if(c[e2[i]]<c[e1[i]])
			swap(e1[i], e2[i]);
		if(c[e1[i]]<c[e2[i]]) {
			va[c[e1[i]]].push_back(i);
			vr[c[e2[i]]].push_back(i);
		}
	}
	for(int i=0; i<n; ++i) {
		for(int j : vr[i])
			s.erase(j);
		for(int j : va[i])
			s.insert(j);
		int mj=-1;
		for(int j : vp[i])
			if(mj<0||a[j][0]+a[j][1]<a[mj][0]+a[mj][1])
				mj=j;
		if(~mj&&(!s.size()||!cw(e1[*s.begin()], e2[*s.begin()], mj)))
			ans.push_back(mj);
	}
	cout << ans.size() << "\n";
	sort(ans.begin(), ans.end());
	for(int a : ans)
		cout << a+1 << " ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 ms 7552 KB Output is correct
3 Correct 9 ms 7808 KB Output is correct
4 Correct 11 ms 8064 KB Output is correct
5 Correct 19 ms 8704 KB Output is correct
6 Correct 21 ms 8704 KB Output is correct
7 Correct 37 ms 9976 KB Output is correct
8 Correct 17 ms 8448 KB Output is correct
9 Correct 15 ms 8576 KB Output is correct
10 Correct 21 ms 8704 KB Output is correct
11 Correct 22 ms 8832 KB Output is correct
12 Correct 26 ms 9848 KB Output is correct
13 Correct 55 ms 11256 KB Output is correct
14 Correct 45 ms 12280 KB Output is correct
15 Correct 53 ms 13560 KB Output is correct
16 Execution timed out 103 ms 19500 KB Time limit exceeded
17 Execution timed out 220 ms 20128 KB Time limit exceeded
18 Runtime error 54 ms 23288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 53 ms 23288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 56 ms 23544 KB Execution killed with signal 11 (could be triggered by violating memory limits)