# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
543550 |
2022-03-30T21:20:50 Z |
Lobo |
ICC (CEOI16_icc) |
C++17 |
|
535 ms |
804 KB |
#include "icc.h"
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 110;
// int edgset[maxn][maxn];
// void setRoad(int u, int v) {
// cout << "setRoad" << u << " " << v << endl;
// if(u != 1 || v != 4) {
// int x,y; cin >> x >> y;
// edgset[x][y] = edgset[y][x] = 1;
// }
// }
// int query(int sza, int szb, int32_t a[], int32_t b[]) {
// int ans = 0;
// for(int i = 0; i < sza; i++) {
// for(int j = 0; j < szb; j++) {
// ans|= edgset[a[i]][b[j]];
// }
// }
// return ans;
// }
int n, ds[maxn], col[maxn];
vector<int> vc[2][maxn];
int find(int v) {
if(v == ds[v]) return v;
return ds[v] = find(ds[v]);
}
void run(int32_t N) {
n = N;
for(int i = 1; i <= n; i++) {
ds[i] = i;
vc[0][i].pb(i);
col[i] = 0;
}
for(int qt = 0; qt < n-1; qt++) {
set<pair<int,int>> par;
for(int i = 1; i <= n; i++) {
for(int j = i+1; j <= n; j++) {
if(find(i) != find(j)) {
par.insert(mp(i,j));
}
}
}
while(par.size() > 3) {
//coloca randons no primeiro
vector<int> qr[2];
for(int i = 1; i <= n; i++) {
if(find(i) != i) continue;
int colr = rand()%2;
for(auto x : vc[colr][i]) {
qr[rand()%2].pb(x);
}
}
int32_t qra[(int32_t) qr[0].size()];
for(int i = 0; i < qr[0].size(); i++) {
qra[i] = qr[0][i];
}
int32_t qrb[(int32_t) qr[1].size()];
for(int i = 0; i < qr[1].size(); i++) {
qrb[i] = qr[1][i];
}
if(query(qr[0].size(), qr[1].size(), qra, qrb)) {
//é entre um e outro
for(auto x : qr[0]) {
for(auto y : qr[0]) {
par.erase(mp(x,y));
par.erase(mp(y,x));
}
}
for(auto x : qr[1]) {
for(auto y : qr[1]) {
par.erase(mp(x,y));
par.erase(mp(y,x));
}
}
}
else {
for(auto x : qr[0]) {
for(auto y : qr[1]) {
par.erase(mp(x,y));
par.erase(mp(y,x));
}
}
}
}
for(auto X : par) {
int u = X.fr;
int v = X.sc;
int32_t qra[1]; qra[0] = u;
int32_t qrb[1]; qrb[0] = v;
// cout << qt << " " << u << " " << v << " ---- " << query(1,1,qra,qrb) << endl;
if(query(1,1,qra,qrb)) {
//coloca o v no u
int pu = find(u);
int pv = find(v);
ds[pv] = pu;
//os caras com col igual a col[v] ficam com col[u]^1
for(auto x : vc[col[u]][pv]) {
vc[col[u]^1][pu].pb(x);
}
for(auto x : vc[col[u]^1][pv]) {
vc[col[u]][pu].pb(x);
}
setRoad(u,v);
break;
}
}
}
}
// int32_t main() {
// // ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// // freopen("out.out", "w", stdout);
// int N; cin >> N;
// int x,y; cin >> x >> y;
// edgset[x][y] = edgset[y][x] = 1;
// run(N);
// }
Compilation message
icc.cpp: In function 'void run(int32_t)':
icc.cpp:78:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i = 0; i < qr[0].size(); i++) {
| ~~^~~~~~~~~~~~~~
icc.cpp:82:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | for(int i = 0; i < qr[1].size(); i++) {
| ~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
468 KB |
Not all edges were guessed! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
176 ms |
564 KB |
Not all edges were guessed! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
535 ms |
804 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
463 ms |
800 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
448 ms |
800 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
408 ms |
692 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |