Submission #1095321

# Submission time Handle Problem Language Result Execution time Memory
1095321 2024-10-01T21:01:36 Z alexander707070 Triangles (CEOI18_tri) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "trilib.h"

#define MAXN 200007
using namespace std;

int n;

/*static long long *x, *y;
static int queries=0;

static void init() {
	static int is_inited=0;
	if (is_inited)
		return;
	is_inited=1;
	assert(scanf("%d", &n)==1);
	x=(long long*)malloc((n+1)*sizeof(long long));
	y=(long long*)malloc((n+1)*sizeof(long long));
	for (int i=1; i<=n; i++){
        //x[i]=rand()%100+1;
        //y[i]=rand()%100+1;
        cin>>x[i]>>y[i];

		//assert(scanf("%lld%lld", &x[i], &y[i])==2);
    }
}

int get_n() {
	init();
	return n;
}

int is_clockwise(int a, int b, int c) {
	init();
	assert(a>=1 && a<=n);
	assert(b>=1 && b<=n);
	assert(c>=1 && c<=n);
	assert(a!=b && a!=c && b!=c);
	queries++;
        if(queries == 1000 * 1000 + 1)
            printf("Too many queries!");
	return (x[b]-x[a])*(y[c]-y[a])-(x[c]-x[a])*(y[b]-y[a])<0;
}

void give_answer(int s) {
	init();
	printf("%d\n", s);
}*/

bool cmp(int x,int y){
    return is_clockwise(1,x,y);
}

vector<int> l,r,res;
int s[MAXN],ss[MAXN],cnt[MAXN],sol;

void shift(int x){
    for(int i=1;i<=n;i++){
        if(i+x<=n)ss[i+x]=s[i];
        else ss[i+x-n]=s[i];
    }

    for(int i=1;i<=n;i++)s[i]=ss[i];
}

int main(){

    srand(42069);

    n=get_n();

    for(int i=3;i<=n;i++){
        if(!is_clockwise(1,2,i)){
            l.push_back(i);
        }else{
            r.push_back(i);
        }
    }

    sort(l.begin(),l.end(),cmp);
    sort(r.begin(),r.end(),cmp);

    s[1]=1;
    for(int i=0;i<l.size();i++){
        s[i+2]=l[i];
    }

    s[l.size()+2]=2;

    for(int i=0;i<r.size();i++){
        s[l.size()+3+i]=r[i];
    }

    for(int test=1;test<=20;test++){
        res.clear();
        shift(rand()%n);

        for(int i=1;i<=n;i++){
            while(res.size()>=2 and !is_clockwise(res[res.size()-2],res[res.size()-1],s[i])){
                res.pop_back();
            }

            if(cnt[i]==test-1)res.push_back(s[i]);
        }

        for(int i:res)cnt[i]++;
    }

    for(int i=1;i<=n;i++){
        if(cnt[i]==20)sol++;
    }

    give_answer(sol);

    return 0;
}

Compilation message

tri.cpp: In function 'int main()':
tri.cpp:85:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for(int i=0;i<l.size();i++){
      |                 ~^~~~~~~~~
tri.cpp:91:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     for(int i=0;i<r.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -