제출 #229465

#제출 시각아이디문제언어결과실행 시간메모리
229465MarcoMeijerHighway Tolls (IOI18_highway)C++14
0 / 100
21 ms936 KiB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

//===================//
//   begin program   //
//===================//

const int MX = 5e5;
int n, m, a, b;
vi w, u, v;
vi group, visited;

bool sameGroup() {
  RE(i,m) {
    if(group[u[i]] != group[v[i]])  w[i] = 0;
    else                            w[i] = 1;
  }
  ll dist = ask(w);
  return dist%2;
}

void find_pair(int N, vi U, vi V, int A, int B) {
  n=N; a=A; b=B; u=U; v=V;
  m = u.sz;
  // A == 1 and B == 2
  w.resize(m);
  group.resize(n);
  int XOR=0;
  RE(i,17) {
    int bit = (1<<i);
    RE(j,n) group[j] = (j&bit)==0;
    if(sameGroup()) XOR |= bit;
  }
  visited.assign(n, 0);
  RE(i,n) {
    if(visited[i]) continue;
    if((i^XOR) < n) {
      group[i] = 0; group[i^XOR] = 1;
      visited[i] = visited[i^XOR] = 1;
    } else {
      group[i] = 0;
      visited[i] = 1;
    }
  }
  int ones=0;
  RE(i,n) if(group[i]) ones++;
  while(ones != 1) {
    set<int> rem;
    RE(i,n) {
      if(group[i] && rem.sz != ones/2) {
        rem.insert(i);
        group[i] = 0;
      }
    }
    if(sameGroup()) {
      RE(i,n) group[i] = 0;
      for(int i:rem) group[i] = 1;
    }
    ones=0;
    RE(i,n) if(group[i]) ones++;
  }
  int ans = 0;
  RE(i,n) if(group[i]) ans = i;
  answer(ans, ans^XOR);
}

컴파일 시 표준 에러 (stderr) 메시지

highway.cpp: In function 'void find_pair(int, vi, vi, int, int)':
highway.cpp:70:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(group[i] && rem.sz != ones/2) {
                      ~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...