AtCoder Regular Contest 082

Submission #1592290

Source codeソースコード

int main(){
    int n;
    cin>>n;
    int p[100001]={0};
    int ans=0;
    for (int i=1; i<=n; i++) {
        cin>>p[i];
    }
    for (int i=1; i<=n; i++) {
        if(p[i]==i){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission

Task問題 C - Together
User nameユーザ名 kiharaf
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 CE
Score得点 -
Source lengthソースコード長 300 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:3:5: error: ‘cin’ was not declared in this scope
cin>>n;
^
./Main.cpp:11:30: error: ‘swap’ was not declared in this scope
swap(p[i], p[i+1]);
^
./Main.cpp:15:5: error: ‘cout’ was not declared in this scope
cout<<ans<<endl;
^
./Main.cpp:15:16: error: ‘endl’ was not declared in this scope
cout<<ans<<endl;
^

Test case