제출 #985538

#제출 시각아이디문제언어결과실행 시간메모리
985538Alex0x0Stations (IOI20_stations)C++17
컴파일 에러
0 ms0 KiB
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef int lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
#define deb(x) cout << #x": " << (x) << endl;

const lli INF = 1e9 + 12;
const lli N = 1e3 + 12;

vector <vi> adj;

vi tk;
lli curVis = 0;
lli titi = 0;
lli vis[N];

void dfs(lli u, lli dpth){
  // cout << u << ' ';
  vis[u] = curVis;
  if (dpth % 2 == 1) tk[u] = titi++;
  for (auto & i : adj[u]){
    if (vis[i] == curVis) continue;
    dfs(i, dpth+1);
  }
  if (dpth % 2 == 0) tk[u] = titi++;
}

vi label(lli n, lli k, vi u, vi v){
  adj.resize(n + 5);
  for (auto &i : adj) i.clear();
  tk.resize(n);
  for (auto &i : tk) i = -1ll;
  titi = 0;
  fore(i,0,n-1){
    adj[u[i]].pb(v[i]);
    adj[v[i]].pb(u[i]);
  }
  ++curVis;
  dfs(0, 0);
  // cout << ENDL;
  return tk;
}


lli find_next_station(lli s, lli t, vi c){
  // cout << "c: "; for (auto & i : c) cout << i << ' '; cout << ENDL;
  bool minor = true;
  for (auto & i : c) if (i < s) minor = false;
  if (minor){
    fore(i,0,sz(c)-1) if (s < t && t < c[i]) return c[i];
    return c[sz(c)-1];
  }
  else{
    fore(i,1,sz(c)){
      lli xx = s;
      if ((i + 1) < sz(c)) xx = c[i + 1];
      if (c[i] < t && t < xx) return c[i];
    }
    return c[0];
  }
  return c[sz(c)-1];
}

void query(lli a, lli b){
  lli xx = 0;
  while (tk[xx] != a) xx++;
  vi c;
  for(auto & i : adj[xx]) c.pb(tk[i]);
  for (auto & i : c) cout << i << ' '; cout << ENDL;
  sort(all(c));
  cout << find_next_station(a, b, c) << ENDL;
}

int main(){ _
  // freopen("file.in","r",stdin);
  // freopen("file.out","w",stdout);
  // vector<vi> vv;
  lli t; cin >> t;
  while (t--){
    lli n, k; cin >> n >> k;
    vi a(n-1); vi b(n-1);
    fore(i,0,n-1) cin >> a[i] >> b[i];
    vi v = label(n, k, a, b);
    for (auto & i : v) cout << i << ' '; cout << ENDL;
    // vv.pb(v);
    // if (t == 1) continue;
    query(3, 15);
    query(2, 15);
    query(16, 15);
    query(11, 15);
    cout << ENDL << "FIN DE CASO" << ENDL << ENDL << ENDL;
  }
  return 0;
}

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

stations.cpp: In function 'void query(lli, lli)':
stations.cpp:82:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   82 |   for (auto & i : c) cout << i << ' '; cout << ENDL;
      |   ^~~
stations.cpp:82:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   82 |   for (auto & i : c) cout << i << ' '; cout << ENDL;
      |                                        ^~~~
stations.cpp: In function 'int main()':
stations.cpp:97:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   97 |     for (auto & i : v) cout << i << ' '; cout << ENDL;
      |     ^~~
stations.cpp:97:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   97 |     for (auto & i : v) cout << i << ' '; cout << ENDL;
      |                                          ^~~~
/usr/bin/ld: /tmp/cc9V1WeZ.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIfm4A0.o:stations.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status