1013 Battle Over Cities
更多...
|
void | dfs (int i, const vector< unordered_set< int > > &g, int occupied, unordered_set< int > &marked) |
|
int | main (istream &cin, ostream &cout) |
|
| TEST (a1013, case1) |
|
◆ dfs()
void pat::a::a1013::dfs |
( |
int | i, |
|
|
const vector< unordered_set< int > > & | g, |
|
|
int | occupied, |
|
|
unordered_set< int > & | marked ) |
在文件 pat.cpp 第 4296 行定义.
4296 {
4297 marked.insert(i);
4298 for(auto nxt: g[i]) {
4299 if(!marked.contains(nxt) && nxt != occupied) {
4300 dfs(nxt, g, occupied, marked);
4301 }
4302 }
4303 }
void dfs(int i, const vector< unordered_set< int > > &g, int occupied, unordered_set< int > &marked)
引用了 dfs().
被这些函数引用 dfs() , 以及 main().
◆ main()
int pat::a::a1013::main |
( |
istream & | cin, |
|
|
ostream & | cout ) |
在文件 pat.cpp 第 4264 行定义.
4264 {
4265 int n, m, k;
4266 cin >> n >> m >> k;
4267 unordered_map<int, int> ans;
4268 vector<unordered_set<int>> g(n + 1);
4269 for(int i = 0; i < m; i++) {
4274 }
4275 for(int i = 0; i < k; i++) {
4278 if(ans.contains(
a)) {
4279 cout << ans[
a] << endl;
4280 continue;
4281 }
4282 unordered_set<int> marked;
4283 int cnt = 0;
4284 for(int j = 1; j <= n; j++) {
4285 if(j !=
a && !marked.contains(j)) {
4286 cnt++;
4287 dfs(j, g,
a, marked);
4288 }
4289 }
4290 cout << cnt - 1 << endl;
4292 }
4293 return 0;
4294 }
vector< vector< int > > ans
引用了 dfs().
被这些函数引用 TEST().
◆ TEST()
pat::a::a1013::TEST |
( |
a1013 | , |
|
|
case1 | ) |
在文件 pat_test.cpp 第 2044 行定义.
2044 {
2045 istringstream in("3 2 3\n"
2046 "1 2\n"
2047 "1 3\n"
2048 "1 2 3");
2049 auto out = ostringstream();
2051 ASSERT_EQ("1\n"
2052 "0\n"
2053 "0\n",
2054 out.str());
2055 }
int main(istream &cin, ostream &cout)
引用了 main().