# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605416 |
2022-07-25T17:20:01 Z |
chirathnirodha |
ICC (CEOI16_icc) |
C++17 |
|
11 ms |
508 KB |
#include "icc.h"
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define I insert
using namespace std;
int n;
int uni[101];
vector<int> v[101];
void solve(vector<int> vc){
set<int> s;s.I(-1);s.I(vc.size()-1);
vector<int> a,b;
while(true){
vector<int> v3;
a.clear();b.clear();
auto itr=s.begin();
while(true){
int l=*itr;l++;
itr++;if(itr==s.end())break;
int r=*itr;
int m=(l+r)/2;
v3.PB(m);
for(int i=l;i<=m;i++){
for(int j=0;j<v[vc[i]].size();j++)a.PB(v[vc[i]][j]);
}
for(int i=m+1;i<=r;i++){
for(int j=0;j<v[vc[i]].size();j++)b.PB(v[vc[i]][j]);
}
}
int arr1[a.size()],arr2[b.size()];
for(int i=0;i<a.size();i++)arr1[i]=a[i];
for(int i=0;i<b.size();i++)arr2[i]=b[i];
bool bl=query(a.size(),b.size(),arr1,arr2);
if(bl)break;
for(int i=0;i<v3.size();i++)s.I(v3[i]);
}
while(true){
if(a.size()==1 && b.size()==1)break;
vector<int> v1,v2,v3;
if(a.size()<b.size()){
vector<int> c;
for(int i=0;i<a.size();i++)c.PB(a[i]);
a.clear();
for(int i=0;i<b.size();i++)a.PB(b[i]);
b.clear();
for(int i=0;i<c.size();i++)b.PB(c[i]);
}
int m=(0+a.size()-1)/2;
for(int i=0;i<=m;i++)v1.PB(a[i]);
for(int i=0;i<b.size();i++)v2.PB(b[i]);
int arr1[v1.size()],arr2[v2.size()];
for(int i=0;i<v1.size();i++)arr1[i]=v1[i];
for(int i=0;i<v2.size();i++)arr2[i]=v2[i];
bool bl=query(v1.size(),v2.size(),arr1,arr2);
if(bl)for(int i=0;i<=m;i++)v3.PB(a[i]);
else for(int i=m+1;i<a.size();i++)v3.PB(a[i]);
a.clear();
for(int i=0;i<v3.size();i++)a.PB(v3[i]);
}
setRoad(a[0],b[0]);
int prunib=uni[b[0]];
for(int i=1;i<=n;i++){
if(uni[i]==prunib){
uni[i]=uni[a[0]];
v[uni[a[0]]].PB(i);
}
}
v[b[0]].clear();
}
void run(int N){
n=N;
for(int i=1;i<=n;i++){
uni[i]=i;
v[i].PB(i);
}
for(int i=0;i<n-1;i++){
vector<int> remu;
for(int j=1;j<=n;j++)if(v[j].size()>0)remu.PB(j);
solve(remu);
}
}
Compilation message
icc.cpp: In function 'void solve(std::vector<int>)':
icc.cpp:26:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int j=0;j<v[vc[i]].size();j++)a.PB(v[vc[i]][j]);
| ~^~~~~~~~~~~~~~~~
icc.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int j=0;j<v[vc[i]].size();j++)b.PB(v[vc[i]][j]);
| ~^~~~~~~~~~~~~~~~
icc.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i=0;i<a.size();i++)arr1[i]=a[i];
| ~^~~~~~~~~
icc.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i=0;i<b.size();i++)arr2[i]=b[i];
| ~^~~~~~~~~
icc.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(int i=0;i<v3.size();i++)s.I(v3[i]);
| ~^~~~~~~~~~
icc.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i=0;i<a.size();i++)c.PB(a[i]);
| ~^~~~~~~~~
icc.cpp:46:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i=0;i<b.size();i++)a.PB(b[i]);
| ~^~~~~~~~~
icc.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(int i=0;i<c.size();i++)b.PB(c[i]);
| ~^~~~~~~~~
icc.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=0;i<b.size();i++)v2.PB(b[i]);
| ~^~~~~~~~~
icc.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i=0;i<v1.size();i++)arr1[i]=v1[i];
| ~^~~~~~~~~~
icc.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=0;i<v2.size();i++)arr2[i]=v2[i];
| ~^~~~~~~~~~
icc.cpp:59:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | else for(int i=m+1;i<a.size();i++)v3.PB(a[i]);
| ~^~~~~~~~~
icc.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for(int i=0;i<v3.size();i++)a.PB(v3[i]);
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
500 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
508 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |