# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
318344 |
2020-11-01T11:19:08 Z |
neki |
ICC (CEOI16_icc) |
C++14 |
|
2 ms |
492 KB |
#include <bits/stdc++.h>
#include "icc.h"
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll int
#define loop(i, a, b) for(ll i=a;i<b;i++)
#define pool(i, a, b) for(ll i=a-1;i>=b;i--)
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 200100
#define pa pair<ll, ll>
#define ld long double
vc<vc<ll>> dsu;
ll que(ll sa, ll sb, vc<ll> a, vc<ll> b){
ll qa[sa], qb[sb];
loop(i, 0, sa) qa[i]=a[i];
loop(i, 0, sb) qb[i]=b[i];
return query(sa, sb, qa, qb);
}
void run(int n){
loop(i, 1, n+1) dsu.ps(vc<ll> {i});
loop(cnt, 0, n-1){
vc<pa> ints={make_pair(0, dsu.size())};
vc<ll> a[2];
do{
vc<pa> ne;
fore(v, ints){
if(v.se-v.fi>1)ne.ps(make_pair(v.fi, (v.fi+v.se)/2)), ne.ps(make_pair((v.fi+v.se)/2, v.se));
else ne.ps(v);
}
ints=ne;
bool br=0;
fore(v, ints){
loop(j, v.fi, v.se) a[br].insert(a[br].end(), all(dsu[j]));
br=!br;
}
}while(!que(a[0].size(), a[1].size(), a[0], a[1]));
while(a[0].size()>1){
vc<ll> b[2];
loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
if(que(a[1].size(), b[0].size(), a[1], b[0])) a[0]=b[0];
else a[0]=b[1];
}
swap(a[0], a[1]);
while(a[0].size()>1){
vc<ll> b[2];
loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
if(que(a[1].size(), b[0].size(), a[1], b[0])) a[0]=b[0];
else a[0]=b[1];
}
ll aa=a[0][0], ab=a[1][0];
ll da, db;
loop(j, 0, dsu.size()){
fore(v, dsu[j]) if(v==aa)da=j;
fore(v, dsu[j]) if(v==ab)db=j;
}
vc<ll> save=dsu[db];dsu.erase(dsu.begin()+db);
dsu[ab].insert(dsu[ab].end(), all(save));
setRoad(aa, ab);
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
55 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ~~~~~~~~~~~~~~~~~
icc.cpp:55:13: note: in expansion of macro 'loop'
55 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ^~~~
icc.cpp:55:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ~^~~~~~~~~~~~~~
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
62 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ~~~~~~~~~~~~~~~~~
icc.cpp:62:13: note: in expansion of macro 'loop'
62 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ^~~~
icc.cpp:62:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | loop(j, 0, a[0].size()) b[j<a[0].size()/2].ps(a[0][j]);
| ~^~~~~~~~~~~~~~
icc.cpp:13:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | #define loop(i, a, b) for(ll i=a;i<b;i++)
......
70 | loop(j, 0, dsu.size()){
| ~~~~~~~~~~~~~~~~
icc.cpp:70:9: note: in expansion of macro 'loop'
70 | loop(j, 0, dsu.size()){
| ^~~~
icc.cpp:69:12: warning: variable 'da' set but not used [-Wunused-but-set-variable]
69 | ll da, db;
| ^~
icc.cpp:74:27: warning: 'db' may be used uninitialized in this function [-Wmaybe-uninitialized]
74 | vc<ll> save=dsu[db];dsu.erase(dsu.begin()+db);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |