답안 #320613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320613 2020-11-09T08:52:32 Z tasfiq4 CEOI16_icc (CEOI16_icc) C++14
0 / 100
1 ms 364 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(),h.size(),a,b)) return {0,0};
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(query(g.size(),mid,a,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,x,a,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: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;
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -