Submission #1607323
Source Code Expand
#include <bits/stdc++.h> using namespace std; namespace { typedef double real; typedef long long ll; template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) { if (vs.empty()) return os << "[]"; auto i = vs.begin(); os << "[" << *i; for (++i; i != vs.end(); ++i) os << " " << *i; return os << "]"; } template<class T> istream& operator>>(istream& is, vector<T>& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int N; vector<int> P; void input() { cin >> N; P.resize(N); cin >> P; } void solve() { int ans = 0; for (int i = 0; i < P.size(); i++) { auto p = P[i]; if (p == i + 1) { ans++; swap(P[i], P[i + 1]); } } cout << ans << endl; } } int main() { input(); solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Derangement |
User | izuru |
Language | C++14 (Clang 3.8.0) |
Score | 0 |
Code Size | 1014 Byte |
Status | CE |
Compile Error
./Main.cpp:1:10: fatal error: 'bits/stdc++.h' file not found #include <bits/stdc++.h> ^ 1 error generated.