이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "insects.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int min_cardinality(int n) {
vector <int> act;
bool used[n + 1];
fill(used, used + n + 1, false);
for(int i = 0; i < n; i++){
move_inside(i);
int x = press_button();
if(x == 2) move_outside(i), used[i] = true;
else act.pb(i);
}
//for(int to : act) cout << to << ' ';
//int l = 0, r = act.size();
for(int to : act) move_outside(to);
int L[n], R[n];
for(int i = 0; i < n; i++){
if(used[i]) L[i] = -1, R[i] =act.size()- 1;
}
for(int j = 0; j < 11; j++){
vector <vector <int> > vv(act.size());
for(int i = 0; i < n; i++){
if(L[i] - R[i] == -1) continue;
if(!used[i]) continue;
int mid = L[i] + R[i];
mid /= 2;
// cout << mid << "\n";
vv[mid].pb(i);
}
for(int i= 0; i < act.size(); i++){
move_inside(act[i]);
for(int to : vv[i]){
move_inside(to);
int x = press_button();
if(x == 2) R[to] = i;
else L[to] = i;
move_outside(to);
}
}
for(int to : act) move_outside(to);
}
int cnt[n + 1];
fill(cnt, cnt + n + 1, 1e9);
for(int j = 0; j < act.size(); j++){
cnt[j] = 1;
}
for(int i = 0; i < n; i++){
if(used[i]) cnt[R[i]]++;
}
int mn = 1e9;
for(int i = 0; i < act.size(); i++){
mn = min(mn, cnt[i]);
}
return mn;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i= 0; i < act.size(); i++){
| ~~^~~~~~~~~~~~
insects.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int j = 0; j < act.size(); j++){
| ~~^~~~~~~~~~~~
insects.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int i = 0; i < act.size(); i++){
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |