#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define getchar_unlocked getchar
#define putchar_unlocked putchar
const int mxN=2e5;
int n, b[mxN], c[mxN+1], e1[mxN], e2[mxN], a1, t[2][mxN], tp[mxN], od[mxN+1], om[mxN+1];
array<ll, 2> a[mxN+1];
vector<array<int, 2>> r[18];
bool ans[mxN];
int in() {
char c=0;
while(c<'0'||c>'9')
c=getchar_unlocked();
int r=0;
while(c>='0'&&c<='9') {
r=r*10+c-'0';
c=getchar_unlocked();
}
return r;
}
void out(int x) {
int c=0, r=0;
for(; !om[x]; ++c, x=od[x]);
for(; x; x=od[x])
r=r*10+om[x];
for(; r; r=od[r])
putchar_unlocked(om[r]+'0');
while(c--)
putchar_unlocked('0');
}
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];
}
bool scmp(const int &i, const int &j) {
if(i<0)
return 0;
if(j<0)
return 1;
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]);
}
int main() {
n=in();
for(int i=0; i<n; ++i)
a[i]={in(), in()};
a[n]=a[0];
iota(b, b+n, 0);
sort(b, b+n, pcmp);
memset(tp, -1, 4*n);
for(int i=0, j=0; i<n; i=j) {
for(; j<n&&a[b[i]][1]*a[b[j]][0]==a[b[j]][1]*a[b[i]][0]; ++j) {
c[b[j]]=i;
if(tp[i]<0||a[b[j]][0]+a[b[j]][1]<a[tp[i]][0]+a[tp[i]][1])
tp[i]=b[j];
}
}
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]]) {
int k=31-__builtin_clz(c[e2[i]]-c[e1[i]]);
r[k].push_back({c[e1[i]], i});
r[k].push_back({c[e2[i]]-(1<<k), i});
}
}
memset(t[1], -1, 4*n);
for(int i=17; ~i; --i) {
for(array<int, 2> a : r[i])
t[i&1][a[0]]=min(a[1], t[i&1][a[0]], scmp);
if(i) {
memset(t[i&1^1], -1, 4*n);
for(int j=0; j<=n-(1<<i); ++j) {
t[i&1^1][j]=min(t[i&1][j], t[i&1^1][j], scmp);
t[i&1^1][j+(1<<i-1)]=min(t[i&1][j], t[i&1^1][j+(1<<i-1)], scmp);
}
}
}
for(int i=0; i<n; ++i)
if(~tp[i]&&(t[0][i]<0||!cw(e1[t[0][i]], e2[t[0][i]], tp[i])))
ans[tp[i]]=1;
for(int i=0; i<n; ++i)
a1+=ans[i];
for(int i=0; i*10<=n; ++i) {
for(int j=0; j<=9&&i*10+j<=n; ++j) {
od[i*10+j]=i;
om[i*10+j]=j;
}
}
out(a1);
putchar_unlocked('\n');
for(int i=0; i<n; ++i) {
if(ans[i]) {
out(i+1);
putchar_unlocked(' ');
}
}
}
Compilation message
circuit.cpp: In function 'int main()':
circuit.cpp:87:14: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
memset(t[i&1^1], -1, 4*n);
~^~
circuit.cpp:89:8: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
t[i&1^1][j]=min(t[i&1][j], t[i&1^1][j], scmp);
~^~
circuit.cpp:89:35: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
t[i&1^1][j]=min(t[i&1][j], t[i&1^1][j], scmp);
~^~
circuit.cpp:90:8: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
t[i&1^1][j+(1<<i-1)]=min(t[i&1][j], t[i&1^1][j+(1<<i-1)], scmp);
~^~
circuit.cpp:90:21: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
t[i&1^1][j+(1<<i-1)]=min(t[i&1][j], t[i&1^1][j+(1<<i-1)], scmp);
~^~
circuit.cpp:90:44: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
t[i&1^1][j+(1<<i-1)]=min(t[i&1][j], t[i&1^1][j+(1<<i-1)], scmp);
~^~
circuit.cpp:90:57: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
t[i&1^1][j+(1<<i-1)]=min(t[i&1][j], t[i&1^1][j+(1<<i-1)], scmp);
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Incorrect |
3 ms |
700 KB |
Output isn't correct |
4 |
Incorrect |
3 ms |
664 KB |
Output isn't correct |
5 |
Correct |
7 ms |
1280 KB |
Output is correct |
6 |
Correct |
7 ms |
1280 KB |
Output is correct |
7 |
Incorrect |
14 ms |
2048 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
1152 KB |
Output isn't correct |
9 |
Incorrect |
6 ms |
1280 KB |
Output isn't correct |
10 |
Correct |
7 ms |
1280 KB |
Output is correct |
11 |
Incorrect |
8 ms |
1408 KB |
Output isn't correct |
12 |
Incorrect |
10 ms |
2048 KB |
Output isn't correct |
13 |
Incorrect |
18 ms |
2796 KB |
Output isn't correct |
14 |
Incorrect |
18 ms |
3448 KB |
Output isn't correct |
15 |
Incorrect |
22 ms |
4084 KB |
Output isn't correct |
16 |
Correct |
45 ms |
7528 KB |
Output is correct |
17 |
Correct |
67 ms |
7784 KB |
Output is correct |
18 |
Correct |
93 ms |
14356 KB |
Output is correct |
19 |
Incorrect |
93 ms |
14600 KB |
Output isn't correct |
20 |
Execution timed out |
153 ms |
14472 KB |
Time limit exceeded |