제출 #781327

#제출 시각아이디문제언어결과실행 시간메모리
781327OrazBSimurgh (IOI17_simurgh)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "simurgh.h" using namespace std; #define pb push_back const int N = 505; int par[N], vis[N], pos[N][N], cur[N], good[N][N], nw[N]; vector<int> E[N]; void dfs(int nd, int pr, vector<int>&vec){ par[nd] = pr; vis[nd] = 1; for (auto i : E[nd]){ if (!vis[i]){ vec.pb(pos[nd][i]); cur[pos[nd][i]] = 1; dfs(i, nd, vec); } } } int conv(vector<int> vec, int x, int y){ for (int i = 0; i < vec.size(); i++) if (vec[i] == x) vec[i] = y; return count_common_roads(vec); } vector<int> find_roads(int n, vector<int> u, vector<int> v){ for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++) pos[i][j] = -1; } for (int i = 0; i < u.size(); i++){ u[i]++; v[i]++; E[u[i]].pb(v[i]); E[v[i]].pb(u[i]); pos[u[i]][v[i]] = i; pos[v[i]][u[i]] = i; } vector<int> vec; dfs(1, 0, vec); // for (auto i : vec){ // cout << i << " "; // } int prev = count_common_roads(vec); // cout << prev << '\n'; for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++){ if (pos[i][j] == -1 or cur[pos[i][j]]) continue; int a = j, b = par[j]; while(b){ int x = conv(vec, pos[a][b], pos[i][j]); if (x != prev){ if (prev+1 == x){ good[i][j] = good[j][i] = 1; }else if (prev-1 == x){ nw[pos[a][b]] = 1; } break; }else{ a = b; b = par[b]; } } } } vector<int> ans; for (auto i : vec) if (nw[i]) ans.pb(i); for (int i = 0; i < u.size(); i++){ if (good[u[i]][v[i]]) ans.pb(i); } return ans; }

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

simurgh.cpp: In function 'int conv(std::vector<int>, int, int)':
simurgh.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i = 0; i < vec.size(); i++) if (vec[i] == x) vec[i] = y;
      |                  ~~^~~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
simurgh.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
#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...