結果

問題 No.2827 Enter User Name to Play
ユーザー vjudge1
提出日時 2025-04-17 18:06:10
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 321 bytes
コンパイル時間 1,201 ms
コンパイル使用メモリ 129,248 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-17 18:06:15
合計ジャッジ時間 5,033 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1 TLE * 1 -- * 1
other -- * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:14: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
    6 |     int  num[N];
      |              ^
main.cpp:6:14: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:5:9: note: declared here
    5 |     int N;
      |         ^
main.cpp:7:13: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
    7 |     char og[N+1];
      |             ^~~
main.cpp:7:13: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:5:9: note: declared here
    5 |     int N;
      |         ^
main.cpp:8:18: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
    8 |     char newchar[N];
      |                  ^
main.cpp:8:18: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:5:9: note: declared here
    5 |     int N;
      |         ^
main.cpp:6:14: warning: variable 'N' is uninitialized when used here [-Wuninitialized]
    6 |     int  num[N];
      |              ^
main.cpp:5:10: note: initialize the variable 'N' to silence this warning
    5 |     int N;
      |          ^
      |           = 0
4 warnings generated.

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
    int N;
    int  num[N];
    char og[N+1];
    char newchar[N];
    cin>>N;
    for(int i=0;i<N;i++) cin>>og[i];
    for(int i=0;i<N;i++) {
        cin>>num[i];
        newchar[i]=og[num[i]-1];
    }
    for(int i=0;i<N;i++) cout<<newchar[i];
    

    return 0;
}
0