problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing4303类 参考

AcWing 4303. 链表 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 4303. 链表

在文件 acwing.h1319 行定义.

成员函数说明

◆ main()

int acwing::acwing4303::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp4254 行定义.

4254 {
4255 int q;
4256 cin >> q;
4257 auto um = unordered_map<string, vector<string> *>();
4258 for(int i = 0; i < q; i++) {
4259 string str1;
4260 string str2;
4261 cin >> str1 >> str2;
4262 if(!um.contains(str1)) {
4263 auto *vec = new vector<string>();
4264 vec->push_back(str1);
4265 vec->push_back(str2);
4266 um.insert(make_pair(str2, vec));
4267 } else {
4268 um[str1]->push_back(str2);
4269 um[str2] = um[str1];
4270 um[str1] = nullptr;
4271 }
4272 }
4273 int count = 0;
4274 for(auto [k, v]: um) {
4275 if(v != nullptr) {
4276 count++;
4277 }
4278 }
4279 cout << count << endl;
4280 for(auto [k, v]: um) {
4281 if(v != nullptr) {
4282 cout << *v->begin() << " " << k << endl;
4283 delete v;
4284 }
4285 }
4286 return 0;
4287 }
int vec[100010]
Definition: pat.cpp:5095

该类的文档由以下文件生成: