# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720287 |
2023-04-07T20:28:49 Z |
groshi |
ICC (CEOI16_icc) |
C++17 |
|
1 ms |
468 KB |
#include<bits/stdc++.h>
#include "icc.h"
using namespace std;
vector<int> spojne[200];
vector<int> mam;
int n;
int aaa[200],bbb[200];
/*bool query(int a,int b,vector<int> a1,vector<int> b1)
{
for(int i=0;i<a1.size();i++)
cout<<a1[i]<<" ";
cout<<"\n";
for(int i=0;i<b1.size();i++)
cout<<b1[i]<<" ";
int co;
cin>>co;
cout<<"\n";
return co;
}
void setRoad(int x,int y)
{
cout<<"mam sciezke "<<x<<" "<<y<<"\n";
}*/
int Query(int a1,int b1,vector<int> a,vector<int> b)
{
for(int i=0;i<a1;i++)
aaa[i]=a[i];
for(int i=0;i<b1;i++)
bbb[i]=b[i];
return query(a1,b1,aaa,bbb);
}
void dodaj(int x,int y)
{
setRoad(x,y);
for(int i=0;i<spojne[x].size();i++)
spojne[y].push_back(spojne[x][i]);
spojne[x].clear();
mam.clear();
for(int i=1;i<=n;i++)
if(spojne[i].size())
mam.push_back(i);
}
void pytaj(vector<pair<int,int>> przedzialy)
{
vector<int> a[2];
for(int i=0;i<przedzialy.size();i++)
{
//cout<<przedzialy[i].first<<" "<<przedzialy[i].second<<"\n";
for(int j=przedzialy[i].first;j<=przedzialy[i].second;j++)
for(int b=0;b<spojne[mam[j]].size();b++)
{
a[i%2].push_back(spojne[mam[j]][b]);
//cout<<"patrze na "<<spojne[mam[j]][b]<<"\n";
}
}
//cout<<"koniec\n";
int co=Query(a[0].size(),a[1].size(),a[0],a[1]);
if(co==0)
{
vector<pair<int,int> > jazda;
for(int i=0;i<przedzialy.size();i++)
{
if(przedzialy[i].first==przedzialy[i].second)
continue;
jazda.push_back({przedzialy[i].first,(przedzialy[i].first+przedzialy[i].second)/2});
jazda.push_back({(przedzialy[i].first+przedzialy[i].second)/2,przedzialy[i].second});
}
pytaj(jazda);
return;
}
int pocz=0,kon=a[0].size(),sre,ostd;
while(pocz<kon)
{
sre=(pocz+kon)/2;
vector<int> pytanko;
for(int i=pocz;i<=sre;i++)
pytanko.push_back(a[0][i]);
int co=Query(pytanko.size(),a[1].size(),pytanko,a[1]);
if(co)
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
int pocz1=0,kon1=a[1].size(),sre1,ostd1;
while(pocz1<kon1)
{
sre1=(pocz1+kon1)/2;
vector<int> pytanko;
for(int i=pocz1;i<=sre1;i++)
pytanko.push_back(a[1][i]);
int co=Query(pytanko.size(),a[0].size(),pytanko,a[0]);
if(co)
{
ostd1=sre1;
kon1=sre1;
}
else pocz1=sre1+1;
}
dodaj(a[0][ostd],a[1][ostd1]);
return;
}
void run(int N)
{
n=N;
for(int i=1;i<=n;i++)
spojne[i].push_back(i),mam.push_back(i);
for(int i=1;i<n;i++)
{
vector<pair<int,int> > przedzialy;
przedzialy.push_back({0,mam.size()/2-1});
przedzialy.push_back({mam.size()/2,mam.size()-1});
pytaj(przedzialy);
}
}
Compilation message
icc.cpp: In function 'void dodaj(int, int)':
icc.cpp:35:18: 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<spojne[x].size();i++)
| ~^~~~~~~~~~~~~~~~~
icc.cpp: In function 'void pytaj(std::vector<std::pair<int, int> >)':
icc.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i=0;i<przedzialy.size();i++)
| ~^~~~~~~~~~~~~~~~~~
icc.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int b=0;b<spojne[mam[j]].size();b++)
| ~^~~~~~~~~~~~~~~~~~~~~~
icc.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i=0;i<przedzialy.size();i++)
| ~^~~~~~~~~~~~~~~~~~
icc.cpp:101:32: warning: 'ostd1' may be used uninitialized in this function [-Wmaybe-uninitialized]
101 | dodaj(a[0][ostd],a[1][ostd1]);
| ^
icc.cpp:101:20: warning: 'ostd' may be used uninitialized in this function [-Wmaybe-uninitialized]
101 | dodaj(a[0][ostd],a[1][ostd1]);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
436 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |