# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605395 |
2022-07-25T17:04:45 Z |
chirathnirodha |
ICC (CEOI16_icc) |
C++17 |
|
35 ms |
512 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++){
b.PB(vc[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:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int j=0;j<v[vc[i]].size();j++)b.PB(v[vc[i]][j]);
| ~^~~~~~~~~~~~~~~~
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<a.size();i++)arr1[i]=a[i];
| ~^~~~~~~~~
icc.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i=0;i<b.size();i++)arr2[i]=b[i];
| ~^~~~~~~~~
icc.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0;i<v3.size();i++)s.I(v3[i]);
| ~^~~~~~~~~~
icc.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i=0;i<a.size();i++)c.PB(a[i]);
| ~^~~~~~~~~
icc.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i=0;i<b.size();i++)a.PB(b[i]);
| ~^~~~~~~~~
icc.cpp:49:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int i=0;i<c.size();i++)b.PB(c[i]);
| ~^~~~~~~~~
icc.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i=0;i<b.size();i++)v2.PB(b[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<v1.size();i++)arr1[i]=v1[i];
| ~^~~~~~~~~~
icc.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i=0;i<v2.size();i++)arr2[i]=v2[i];
| ~^~~~~~~~~~
icc.cpp:60:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | else for(int i=m+1;i<a.size();i++)v3.PB(a[i]);
| ~^~~~~~~~~
icc.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i=0;i<v3.size();i++)a.PB(v3[i]);
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
496 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |