結果
| 問題 |
No.938 賢人を探せ
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-12-03 14:29:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,217 bytes |
| コンパイル時間 | 1,220 ms |
| コンパイル使用メモリ | 95,536 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2024-12-14 11:47:10 |
| 合計ジャッジ時間 | 1,836 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:57:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
57 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:62:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%s%s", s0, s1);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 938.cc: No.938 賢人を探せ - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 20000;
const int MAX_M = MAX_N * 2;
/* typedef */
typedef map<string,int> msi;
/* global variables */
msi idmap;
string ss[MAX_M];
int as[MAX_N], bs[MAX_N];
bool es[MAX_M];
/* subroutines */
inline int allocid(char s[], int &n) {
string t(s);
msi::iterator mit = idmap.find(t);
if (mit != idmap.end()) return mit->second;
ss[n] = t;
return (idmap[t] = n++);
}
/* main */
int main() {
int n;
scanf("%d", &n);
int m = 0;
for (int i = 0; i < n; i++) {
char s0[16], s1[16];
scanf("%s%s", s0, s1);
int id0 = allocid(s0, m);
int id1 = allocid(s1, m);
as[i] = id0, bs[i] = id1;
es[id0] = true;
}
for (int i = 0; i < n; i++)
if (! es[bs[i]]) {
puts(ss[bs[i]].c_str());
es[bs[i]] = true;
}
return 0;
}
tnakao0123