답안 #700968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700968 2023-02-19T14:22:03 Z beaconmc CEOI16_icc (CEOI16_icc) C++14
컴파일 오류
0 ms 0 KB
//#include "icc.h"
#include <bits/stdc++.h>


typedef int ll;
using namespace std;


#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


ll a_imp, b_imp;


ll n = 0;

ll cc[200];
int find(ll a){
	while (cc[a] != a){
		cc[a] = cc[cc[a]];
		a = cc[a];
	}
	return a;
}

bool query(ll a, ll b, vector<ll> aa, vector<ll> bb){
	set<ll> sus;
	for (auto&i : aa) sus.insert(i);
	for (auto&i : bb) sus.insert(i);

	if (sus.size() != aa.size() + bb.size()){
		cout << a <<" " << b << endl;
		for (auto&i : aa) cout << i << " ";
			cout << endl;
		for (auto&i : bb) cout << i << " ";
			cout << endl;
		cout << "UWU" << endl;
	}

	bool left = 0, right = 0;
	bool ll=0, rr = 0;
	for (auto&i : aa) if (i==a_imp) left = 1;
	for (auto&i : bb) if (i==b_imp) right = 1;

	for (auto&i : aa) if (i==b_imp) ll = 1;
	for (auto&i : bb) if (i==a_imp) rr = 1;



	return (left&right) | (ll & rr);
}


void unite(ll a, ll b){
	cc[find(a)] = find(b);
}

bool unpackquery(vector<ll> a, vector<ll> b){
	vector<vector<ll>> unpacked(n+1);
	FOR(i,1,n+1) unpacked[find(i)].push_back(i);

	vector<ll> aa, bb;
	for (auto&i : a){
		for (auto&k : unpacked[i]){
			aa.push_back(k);
		}
	}
	for (auto&i : b){
		for (auto&k : unpacked[i]){
			bb.push_back(k);
		}
	}
	return query(aa.size(), bb.size(), aa, bb);
}
bool realquery(vector<ll> a, vector<ll> b){

	return query(a.size(), b.size(), a, b);
}


void uniquesolve(vector<ll> a){
	ll xored = 0;

	FOR(i,0,ceil(log2(a.size()+1))){
		vector<ll> one;
		vector<ll> zero;
		FOR(j,0,a.size()){
			if ((j & (1<<i)) != 0) one.push_back(a[j]);
			else zero.push_back(a[j]);
		}

		xored |= (1<<i) * realquery(one, zero);
	}
	//cout << xored << endl;

	ll xor2 = 0;

	FOR(i,0,ceil(log2(a.size()+1))){
		vector<ll> one;
		vector<ll> anti;

		FOR(j,0,a.size()){
			if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
			if ((xored ^ j) == j) continue;
			if ((j & (1<<i)) != 0) one.push_back(j);
		}
		for (auto&j : one){
			if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
			if ((xored ^ j) == j) continue;
			anti.push_back(xored ^ j);
		}

		FOR(j,0,one.size()) one[j] = a[one[j]];
		FOR(j,0,anti.size()) anti[j] = a[anti[j]];



		xor2 |= (1<<i) * realquery(one, anti);

	}
	cout << a[xor2] <<" " << a[xored^xor2] <<  endl;
	unite(a[xor2], a[xored^xor2]);

}

void solve(vector<ll> a){
	vector<vector<ll>> unpacked(n+1);
	FOR(i,1,n+1) unpacked[find(i)].push_back(i);

	set<ll> idk;
	for (auto&i : a) idk.insert(find(i));

	a.clear();
    for (auto&i : idk) a.push_back(i);
	ll xored = 0;


	FOR(i,0,ceil(log2(a.size()+1))){
		vector<ll> one;
		vector<ll> zero;
		FOR(j,0,a.size()){

			if ((j & (1<<i)) != 0) one.push_back(a[j]);
			else zero.push_back(a[j]);
		}

		xored |= (1<<i) * unpackquery(one, zero);
	}
	//cout << xored << endl;

	ll xor2 = 0;

	FOR(i,0,ceil(log2(a.size()+1))){
		vector<ll> one;
		vector<ll> anti;

		FOR(j,0,a.size()){
			if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
			if ((xored ^ j) == j) continue;
			if ((j & (1<<i)) != 0) one.push_back(j);
		}
		for (auto&j : one){
			if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
			if ((xored ^ j) == j) continue;
			anti.push_back(xored ^ j);
		}



		FOR(j,0,one.size()) one[j] = a[one[j]];
		FOR(j,0,anti.size()) anti[j] = a[anti[j]];



		xor2 |= (1<<i) * unpackquery(one, anti);


	}
	vector<ll> news;
	//cout << a[xor2] << " " << a[xored^xor2] << endl;

	for (auto&i : unpacked[find(a[xor2])]){
		//cout << i << " ";
		news.push_back(i);
	}
	for (auto&i : unpacked[find(a[xored^xor2])]){
		//cout << i <<" ";
		news.push_back(i);
	}
	//cout << "SUS" << endl;
	//cout << news.size() << endl;
	uniquesolve(news);
}



void run(int N){
	n = N;
	FOR(i,0,200) cc[i] = i;
	vector<ll> sus(n);
	FOR(i,0,n) sus[i] = i+1;
	a_imp = 5;
	b_imp = 4;
	solve(sus);
	a_imp = 2;
	b_imp = 3;
	solve(sus);
	a_imp = 10;
	b_imp = 5;
	solve(sus);
	a_imp = 10;
	b_imp = 8;
	solve(sus);
	a_imp = 1;
	b_imp = 5;
	solve(sus);
}

int main(){

	run(10);
}

Compilation message

icc.cpp: In function 'void uniquesolve(std::vector<int>)':
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   89 |   FOR(j,0,a.size()){
      |       ~~~~~~~~~~~~                 
icc.cpp:89:3: note: in expansion of macro 'FOR'
   89 |   FOR(j,0,a.size()){
      |   ^~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  104 |   FOR(j,0,a.size()){
      |       ~~~~~~~~~~~~                 
icc.cpp:104:3: note: in expansion of macro 'FOR'
  104 |   FOR(j,0,a.size()){
      |   ^~~
icc.cpp:105:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |    if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
      |        ~~~~~~~~~~~~^~~~~~~~~~~
icc.cpp:110:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |    if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
      |        ~~~~~~~~~~~~^~~~~~~~~~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  115 |   FOR(j,0,one.size()) one[j] = a[one[j]];
      |       ~~~~~~~~~~~~~~               
icc.cpp:115:3: note: in expansion of macro 'FOR'
  115 |   FOR(j,0,one.size()) one[j] = a[one[j]];
      |   ^~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  116 |   FOR(j,0,anti.size()) anti[j] = a[anti[j]];
      |       ~~~~~~~~~~~~~~~              
icc.cpp:116:3: note: in expansion of macro 'FOR'
  116 |   FOR(j,0,anti.size()) anti[j] = a[anti[j]];
      |   ^~~
icc.cpp: In function 'void solve(std::vector<int>)':
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  143 |   FOR(j,0,a.size()){
      |       ~~~~~~~~~~~~                 
icc.cpp:143:3: note: in expansion of macro 'FOR'
  143 |   FOR(j,0,a.size()){
      |   ^~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  159 |   FOR(j,0,a.size()){
      |       ~~~~~~~~~~~~                 
icc.cpp:159:3: note: in expansion of macro 'FOR'
  159 |   FOR(j,0,a.size()){
      |   ^~~
icc.cpp:160:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  160 |    if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
      |        ~~~~~~~~~~~~^~~~~~~~~~~
icc.cpp:165:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  165 |    if ((xored ^ j) >= a.size() || j < (xored^j)) continue;
      |        ~~~~~~~~~~~~^~~~~~~~~~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  172 |   FOR(j,0,one.size()) one[j] = a[one[j]];
      |       ~~~~~~~~~~~~~~               
icc.cpp:172:3: note: in expansion of macro 'FOR'
  172 |   FOR(j,0,one.size()) one[j] = a[one[j]];
      |   ^~~
icc.cpp:9:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
  173 |   FOR(j,0,anti.size()) anti[j] = a[anti[j]];
      |       ~~~~~~~~~~~~~~~              
icc.cpp:173:3: note: in expansion of macro 'FOR'
  173 |   FOR(j,0,anti.size()) anti[j] = a[anti[j]];
      |   ^~~
/usr/bin/ld: /tmp/ccfhqQfh.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccNzps9e.o:icc.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccfhqQfh.o: in function `main':
grader.cpp:(.text.startup+0x17): undefined reference to `run'
collect2: error: ld returned 1 exit status