結果

問題 No.2827 Enter User Name to Play
ユーザー k82b
提出日時 2024-08-02 21:21:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 28,160 KB
最終ジャッジ日時 2025-02-23 19:49:53
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%s", S);
      |         ~~~~~^~~~~~~~~
main.cpp:16:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         for (int i = 0; i < N; ++i) scanf("%d", &P[i]);
      |                                     ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

using namespace std;

using Int = long long;

template <class T> inline bool chmin(T &A, T B) { if (A > B) { A = B; return true; } else { return false; } }
template <class T> inline bool chmax(T &A, T B) { if (A < B) { A = B; return true; } else { return false; } }

#include <cstdio>

int main() {
	int N;
	scanf("%d", &N);
	char S[N + 1];
	scanf("%s", S);
	int P[N];
	for (int i = 0; i < N; ++i) scanf("%d", &P[i]);
	char ans[N + 1];
	ans[N] = '\0';
	for (int i = 0; i < N; ++i) {
		ans[i] = S[--P[i]];
	}
	puts(ans);
}
0