Submission #320607

# Submission time Handle Problem Language Result Execution time Memory
320607 2020-11-09T08:47:30 Z tasfiq4 ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int > pii;
typedef long long int lld;
#define pi acos(-1)
#define fr(i,m,n) for(i=m;i<n;i++)
#define fu(i,m,n) for(i=m;i>=n;i--)
#define vec vector<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define all(v) v.begin(),v.end()
#define mom(ara) memset(ara,0,sizeof(ara));
#define m1m(ara) memset(ara,-1,sizeof(ara));
#define endl "\n"
#define eps 1.19209e-07
int dsu[103];
vec grp[103];
int ara[103];
int find(int a)
{
	if(dsu[a]==a) return a;
	return dsu[a]=find(dsu[a]);
}
void uni(int x,int y)
{
	int a,b,i,j;
	a=find(x);
	b=find(y);
	if(grp[a].size()<grp[b].size()) swap(a,b);
	dsu[b]=dsu[a];
	ara[b]=1;
	for(auto x:grp[b]) grp[a].pb(x);
}
pii operate(vec &g,vec &h)
{
	if(g.size()==0 || h.size()==0) return {0,0};
	int a[103],b[103],x,y,i,j;
	fr(i,0,g.size()) a[i]=g[i];
	fr(i,0,h.size()) b[i]=g[i];
	int l=0,r=h.size();
	if(!query(g.size(),a,h.size(),b)) return {0,0};
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(query(g.size(),a,mid,b))
		{
			r=mid;
		}
		else
		{
			l=mid;
		}
	}
	x=r;
	l=0,r=g.size();
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(query(mid,a,x,b))
		{
			r=mid;
		}
		else l=mid;
	}
	y=r;
	return {a[x-1],b[y-1]};
}
void run(int n)
{
	int i,j,k,a,b,c,x,y;
	fr(i,1,n+1)
	{
		dsu[i]=i;
		grp[i].pb(i);
	}
	fr(k,0,n-1)
	{
		fr(i,0,7)
		{
			vec g,h;
			fr(j,1,n+1)
			{
				if(!ara[j])
				{
					if(j&(1<<i))
					{
						for(auto x:grp[j]) g.pb(x);
					}
					else
					{
						for(auto x:grp[j]) h.pb(x);
					}
				}
			}
			pii z=operate(g,h);
			if(z.ft==0) continue;
			else 
			{
				uni(z.ft,z.ft);
				setRoad(z.ft,z.ft)
				break;
			}
		}
	}
}

Compilation message

icc.cpp: In function 'void uni(int, int)':
icc.cpp:28:10: warning: unused variable 'i' [-Wunused-variable]
   28 |  int a,b,i,j;
      |          ^
icc.cpp:28:12: warning: unused variable 'j' [-Wunused-variable]
   28 |  int a,b,i,j;
      |            ^
icc.cpp: In function 'pii operate(std::vector<int>&, std::vector<int>&)':
icc.cpp:6:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define fr(i,m,n) for(i=m;i<n;i++)
......
   40 |  fr(i,0,g.size()) a[i]=g[i];
      |     ~~~~~~~~~~~~            
icc.cpp:40:2: note: in expansion of macro 'fr'
   40 |  fr(i,0,g.size()) a[i]=g[i];
      |  ^~
icc.cpp:6:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define fr(i,m,n) for(i=m;i<n;i++)
......
   41 |  fr(i,0,h.size()) b[i]=g[i];
      |     ~~~~~~~~~~~~            
icc.cpp:41:2: note: in expansion of macro 'fr'
   41 |  fr(i,0,h.size()) b[i]=g[i];
      |  ^~
icc.cpp:43:6: error: 'query' was not declared in this scope
   43 |  if(!query(g.size(),a,h.size(),b)) return {0,0};
      |      ^~~~~
icc.cpp:47:6: error: 'query' was not declared in this scope
   47 |   if(query(g.size(),a,mid,b))
      |      ^~~~~
icc.cpp:61:6: error: 'query' was not declared in this scope
   61 |   if(query(mid,a,x,b))
      |      ^~~~~
icc.cpp:39:26: warning: unused variable 'j' [-Wunused-variable]
   39 |  int a[103],b[103],x,y,i,j;
      |                          ^
icc.cpp: In function 'void run(int)':
icc.cpp:102:5: error: 'setRoad' was not declared in this scope
  102 |     setRoad(z.ft,z.ft)
      |     ^~~~~~~
icc.cpp:72:12: warning: unused variable 'a' [-Wunused-variable]
   72 |  int i,j,k,a,b,c,x,y;
      |            ^
icc.cpp:72:14: warning: unused variable 'b' [-Wunused-variable]
   72 |  int i,j,k,a,b,c,x,y;
      |              ^
icc.cpp:72:16: warning: unused variable 'c' [-Wunused-variable]
   72 |  int i,j,k,a,b,c,x,y;
      |                ^
icc.cpp:72:18: warning: unused variable 'x' [-Wunused-variable]
   72 |  int i,j,k,a,b,c,x,y;
      |                  ^
icc.cpp:72:20: warning: unused variable 'y' [-Wunused-variable]
   72 |  int i,j,k,a,b,c,x,y;
      |                    ^