#include "icc.h"
#include <vector>
using namespace std;
vector<int> children[101];
int parent[101];
int connection1(vector<int> temp, int an, int a[]){
if(temp.size()==1){
return temp[0];
}
int n=temp.size();
int b1[n/2];
for(int i=0;i<n/2;i++){
b1[i]=temp[i];
}
if(query(an, n/2, a, b1)){
vector<int> temp2;
for(int i=0;i<n/2;i++){
temp2.push_back(temp[i]);
}
return connection1(temp2, an, a);
}
else{
vector<int> temp2;
for(int i=n/2;i<n;i++){
temp2.push_back(temp[i]);
}
return connection1(temp2, an, a);
}
}
pair<int, int> connection2(vector<int> temp){
int n=temp.size();
vector<int> tempA, tempB;
for(int i=0;i<n/2;i++){
tempA.push_back(temp[i]);
for(int j=0;j<children[temp[i]].size();j++){
tempA.push_back(children[temp[i]][j]);
}
}
for(int i=n/2;i<n;i++){
tempB.push_back(temp[i]);
for(int j=0;j<children[temp[i]].size();j++){
tempB.push_back(children[temp[i]][j]);
}
}
int a[tempA.size()], b[tempB.size()];
for(int i=0;i<tempA.size();i++){
a[i]=tempA[i];
}
for(int i=0;i<tempB.size();i++){
b[i]=tempB[i];
}
if(query(tempA.size(), tempB.size(), a, b)){
pair<int, int> ans;
vector<int> temp2;
for(int i=0;i<n/2;i++){
temp2.push_back(temp[i]);
for(int j=0;j<children[temp[i]].size();j++){
temp2.push_back(children[temp[i]][j]);
}
}
ans.first=connection1(temp2, tempB.size(), b);
vector<int> temp3;
for(int i=n/2;i<n;i++){
temp3.push_back(temp[i]);
for(int j=0;j<children[temp[i]].size();j++){
temp3.push_back(children[temp[i]][j]);
}
}
ans.second=connection1(temp3, tempA.size(), a);
return ans;
}
else{
vector<int> temp2;
for(int i=0;i<n/2;i++){
temp2.push_back(temp[i]);
}
pair<int, int> ans=connection2(temp2);
if(ans==make_pair(0, 0)){
vector<int> temp3;
for(int i=n/2;i<n;i++){
temp3.push_back(temp[i]);
}
return connection2(temp3);
}
return ans;
}
}
void run(int n) {
vector<int> component;
for(int i=1;i<=n;i++){
component.push_back(i);
parent[i]=i;
}
for(int i=0;i<n-1;i++){
pair<int, int> ans=connection2(component);
setRoad(ans.first, ans.second);
component.erase(lower_bound(component.begin(), component.end(), max(ans.first, ans.second)));
children[parent[min(ans.first, ans.second)]].push_back(max(ans.first, ans.second));
parent[max(ans.first, ans.second)]=parent[min(ans.first, ans.second)];
}
}
Compilation message
icc.cpp: In function 'std::pair<int, int> connection2(std::vector<int>)':
icc.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<children[temp[i]].size();j++){
~^~~~~~~~~~~~~~~~~~~~~~~~~
icc.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<children[temp[i]].size();j++){
~^~~~~~~~~~~~~~~~~~~~~~~~~
icc.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<tempA.size();i++){
~^~~~~~~~~~~~~
icc.cpp:52:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<tempB.size();i++){
~^~~~~~~~~~~~~
icc.cpp:60:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<children[temp[i]].size();j++){
~^~~~~~~~~~~~~~~~~~~~~~~~~
icc.cpp:68:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<children[temp[i]].size();j++){
~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1920 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1664 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1536 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1536 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
1408 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |