제출 #429363

#제출 시각아이디문제언어결과실행 시간메모리
429363Dan4LifeConnecting Supertrees (IOI20_supertrees)C++17
11 / 100
291 ms26868 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; vector<int> v; vector<vector<int>> a; bool vis[1001]; #define pb push_back int N; void dfs(int s, int x) { v.pb(s); vis[s]=true; for(int i = s+1; i < N; i++) if(!vis[i] and a[s][i]==x) dfs(i, x); } int construct(vector<vector<int>> p) { for(auto u : p) for(auto v : u) if(v==3)return 0; N = p.size(), fill(vis,vis+1000,false); for(auto u : p) { vector<int> x; x.clear(); for(auto v : u) x.pb(v); a.pb(x); } vector<vector<int>> answer; vector<int> x; x.clear(); for(int j = 0; j < N; j++)x.pb(0); for(int i = 0; i < N; i++) answer.pb(x); for(int i = 0; i < N; i++) { if(vis[i])continue; v.clear(); dfs(i, 1); for(int j = 0; j < v.size()-1; j++) { answer[v[j]][v[j+1]]=1; } } fill(vis,vis+1000,false); for(int i = 0; i < N; i++) { if(vis[i])continue; v.clear(); dfs(i, 2); if(v.size()<=1)continue; if(v.size()<=2)return 0; for(int j = 0; j < v.size(); j++) { answer[v[j]][v[(j+1)%(int)v.size()]]=1; } } for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) if(answer[i][j]==1)answer[j][i]=1; build(answer); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for(auto u : p)
      |     ^~~
supertrees.cpp:21:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |  N = p.size(), fill(vis,vis+1000,false);
      |  ^
supertrees.cpp:31:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   31 |     for(int i = 0; i < N; i++)
      |     ^~~
supertrees.cpp:33:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   33 |  for(int i =  0; i < N; i++)
      |  ^~~
supertrees.cpp:35:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   35 |         if(vis[i])continue; v.clear();
      |         ^~
supertrees.cpp:35:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |         if(vis[i])continue; v.clear();
      |                             ^
supertrees.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = 0; j < v.size()-1; j++)
      |                        ~~^~~~~~~~~~~~
supertrees.cpp:45:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   45 |         if(vis[i])continue; v.clear();
      |         ^~
supertrees.cpp:45:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   45 |         if(vis[i])continue; v.clear();
      |                             ^
supertrees.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(int j = 0; j < v.size(); j++)
      |                        ~~^~~~~~~~~~
supertrees.cpp:53:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |     for(int i = 0; i < N; i++)
      |     ^~~
supertrees.cpp:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   56 |  build(answer);
      |  ^~~~~
#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...