Submission #320611

# Submission time Handle Problem Language Result Execution time Memory
320611 2020-11-09T08:51:03 Z tasfiq4 ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.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[y-1],b[x-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.sd);
				setRoad(z.ft,z.sd);
				break;
			}
		}
	}
}

Compilation message

icc.cpp: In function 'void uni(int, int)':
icc.cpp:29:10: warning: unused variable 'i' [-Wunused-variable]
   29 |  int a,b,i,j;
      |          ^
icc.cpp:29:12: warning: unused variable 'j' [-Wunused-variable]
   29 |  int a,b,i,j;
      |            ^
icc.cpp: In function 'pii operate(std::vector<int>&, std::vector<int>&)':
icc.cpp:7:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define fr(i,m,n) for(i=m;i<n;i++)
......
   41 |  fr(i,0,g.size()) a[i]=g[i];
      |     ~~~~~~~~~~~~            
icc.cpp:41:2: note: in expansion of macro 'fr'
   41 |  fr(i,0,g.size()) a[i]=g[i];
      |  ^~
icc.cpp:7:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define fr(i,m,n) for(i=m;i<n;i++)
......
   42 |  fr(i,0,h.size()) b[i]=g[i];
      |     ~~~~~~~~~~~~            
icc.cpp:42:2: note: in expansion of macro 'fr'
   42 |  fr(i,0,h.size()) b[i]=g[i];
      |  ^~
icc.cpp:44:21: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   44 |  if(!query(g.size(),a,h.size(),b)) return {0,0};
      |                     ^
      |                     |
      |                     int*
In file included from icc.cpp:2:
icc.h:10:22: note:   initializing argument 2 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                  ~~~~^
icc.cpp:44:29: error: invalid conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int*' [-fpermissive]
   44 |  if(!query(g.size(),a,h.size(),b)) return {0,0};
      |                       ~~~~~~^~
      |                             |
      |                             std::vector<int>::size_type {aka long unsigned int}
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:48:21: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   48 |   if(query(g.size(),a,mid,b))
      |                     ^
      |                     |
      |                     int*
In file included from icc.cpp:2:
icc.h:10:22: note:   initializing argument 2 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                  ~~~~^
icc.cpp:48:23: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   48 |   if(query(g.size(),a,mid,b))
      |                       ^~~
      |                       |
      |                       int
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:62:16: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   62 |   if(query(mid,a,x,b))
      |                ^
      |                |
      |                int*
In file included from icc.cpp:2:
icc.h:10:22: note:   initializing argument 2 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                  ~~~~^
icc.cpp:62:18: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   62 |   if(query(mid,a,x,b))
      |                  ^
      |                  |
      |                  int
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:40:26: warning: unused variable 'j' [-Wunused-variable]
   40 |  int a[103],b[103],x,y,i,j;
      |                          ^
icc.cpp: In function 'void run(int)':
icc.cpp:73:12: warning: unused variable 'a' [-Wunused-variable]
   73 |  int i,j,k,a,b,c,x,y;
      |            ^
icc.cpp:73:14: warning: unused variable 'b' [-Wunused-variable]
   73 |  int i,j,k,a,b,c,x,y;
      |              ^
icc.cpp:73:16: warning: unused variable 'c' [-Wunused-variable]
   73 |  int i,j,k,a,b,c,x,y;
      |                ^
icc.cpp:73:18: warning: unused variable 'x' [-Wunused-variable]
   73 |  int i,j,k,a,b,c,x,y;
      |                  ^
icc.cpp:73:20: warning: unused variable 'y' [-Wunused-variable]
   73 |  int i,j,k,a,b,c,x,y;
      |                    ^