Submission #204113

# Submission time Handle Problem Language Result Execution time Memory
204113 2020-02-24T12:14:02 Z cheetose Meetings (JOI19_meetings) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

#include "meetings.h"
Vi v[2005];
void discon(int x,int y)
{
	for(int &z:v[x])
	{
		if(z==y)
		{
			z=v[x].back();
			v[x].back()=y;
		}
	}
	for(int &z:v[y])
	{
		if(z==x)
		{
			z=v[y].back();
			v[y].back()=x;
		}
	}
	v[x].pop_back();
	v[y].pop_back();
}
void con(int x,int y)
{
	v[x].pb(y);
	v[y].pb(x);
}

bool chk[2005],kill[2005];
int sz[2005];
int getSz(int N,int pp)
{
    sz[N]=1;
    for(int next:v[N])
	{
        if(next==pp || kill[next])continue;
        sz[N]+=getSz(next,N);
    }
    return sz[N];
}
int get_centroid(int N,int pp,int cap)
{
    for(int next:v[N])
	{
        if(kill[next] || next==pp)continue;
        if(sz[next]>cap) return get_centroid(next,N,cap);
    }
    return N;
}
void Solve(int N)
{
	chk[0]=chk[1]=chk[2]=1;
	int w=Query(0,1,2);
	if(w>2)
	{
		chk[w]=1;
		con(0,w);con(1,w);con(2,w);
	}
	else
	{
		fup(i,0,2,1)if(w!=i)con(i,w);
	}
	fup(i,3,N-1,1)
	{
		if(chk[i])continue;
		chk[i]=1;
		MEM0(kill);
		int pr=0;
		while(1)
		{
			int cap=getSz(pr,-1);
			int R=get_centroid(pr,-1,cap/2);
			kill[R]=1;
			Vi w;
			fup(j,1,(int)v[R].size()-1,2)
			{
				int a=v[R][j-1],b=v[R][j];
				int x=Query(a,i,b);
				if(x==i)
				{
					int T=Query(R,i,a);
					if(T==i)
					{
						discon(R,a);
						con(R,i);con(i,a);
					}
					else
					{
						discon(R,b);
						con(R,i);con(i,b);
					}
					goto FIN;
				}
				else w.pb(x);
			}
			if(v[R].size()&1)
			{
				int x=Query(R,i,v[R].back());
				if(x==i)
				{
					discon(R,v[R].back());
					con(R,i);con(i,v[R].back());
					goto FIN;
				}
				else w.pb(x);
			}
			int t=-1;
			for(int x:w)if(x!=R)t=x;
			if(t==-1)
			{
				con(R,i);
				goto FIN;
			}
			else
			{
				pr=t;
			}
		}
FIN:;
	}
	fup(i,1,n,1)
	{
		for(int x:v[i])
		{
			if(x>i)Bridge(i,x);
		}
	}
}/*
int main(){

}*/

Compilation message

meetings.cpp:72:25: error: 'bool kill [2005]' redeclared as different kind of symbol
 bool chk[2005],kill[2005];
                         ^
In file included from /usr/include/c++/7/csignal:42:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:43,
                 from meetings.cpp:1:
/usr/include/signal.h:127:12: note: previous declaration 'int kill(__pid_t, int)'
 extern int kill (__pid_t __pid, int __sig) __THROW;
            ^~~~
meetings.cpp: In function 'int getSz(int, int)':
meetings.cpp:79:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         if(next==pp || kill[next])continue;
                                 ^
meetings.cpp: In function 'int get_centroid(int, int, int)':
meetings.cpp:88:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
         if(kill[next] || next==pp)continue;
                     ^
meetings.cpp: In function 'void Solve(int)':
meetings.cpp:12:38: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
 #define MEM0(a) memset((a),0,sizeof(a));
                                      ^
meetings.cpp:110:3: note: in expansion of macro 'MEM0'
   MEM0(kill);
   ^~~~
meetings.cpp:110:8: error: invalid conversion from 'int (*)(__pid_t, int) noexcept {aka int (*)(int, int) noexcept}' to 'void*' [-fpermissive]
meetings.cpp:12:24:
 #define MEM0(a) memset((a),0,sizeof(a));
                        ~~~
meetings.cpp:110:8:
   MEM0(kill);
meetings.cpp:12:25: note: in definition of macro 'MEM0'
 #define MEM0(a) memset((a),0,sizeof(a));
                         ^
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from meetings.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string3.h:78:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
 __NTH (memset (void *__dest, int __ch, size_t __len))
 ^
meetings.cpp:116:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    kill[R]=1;
          ^
meetings.cpp:116:12: error: assignment of read-only location '*(kill + ((sizetype)R))'
    kill[R]=1;
            ^
meetings.cpp:116:12: error: cannot convert 'int' to 'int(__pid_t, int) noexcept {aka int(int, int) noexcept}' in assignment
meetings.cpp:164:10: error: 'n' was not declared in this scope
  fup(i,1,n,1)
          ^
meetings.cpp:10:44: note: in definition of macro 'fup'
 #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
                                            ^