Submission #1627359
Source Code Expand
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define REP(i, m, n) for(int i=int(m);i<int(n);i++) #define EACH(i, c) for (auto &(i): c) #define all(c) begin(c),end(c) #define EXIST(s, e) ((s).find(e)!=(s).end()) #define SORT(c) sort(begin(c),end(c)) #define pb emplace_back #define MP make_pair #define SZ(a) int((a).size()) //#define LOCAL 1 #ifdef LOCAL #define DEBUG(s) cout << (s) << endl #define dump(x) cerr << #x << " = " << (x) << endl #define BR cout << endl; #else #define DEBUG(s) do{}while(0) #define dump(x) do{}while(0) #define BR #endif //改造 typedef long long int ll; using namespace std; //ここから編集する ll mod = 1000000007; int main() { int N; cin >> N; vector<int> v(N+1); REP(i,1,N+1){ cin >> v[i]; } int cnt = 0; for(int i = 1; i < v.size(); ){ if(v[i] == i){ if(v[i + 1] == i + 1){ i+=2; cnt++; }else{ i++; cnt++; } }else{ i++; } } cout << cnt << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Derangement |
User | homesentinel |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1736 Byte |
Status | AC |
Exec Time | 31 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
0_003.txt | AC | 1 ms | 256 KB |
1_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 29 ms | 640 KB |
1_006.txt | AC | 29 ms | 640 KB |
1_007.txt | AC | 29 ms | 640 KB |
1_008.txt | AC | 31 ms | 640 KB |
1_009.txt | AC | 29 ms | 640 KB |
1_010.txt | AC | 31 ms | 640 KB |
1_011.txt | AC | 29 ms | 640 KB |
1_012.txt | AC | 30 ms | 640 KB |
1_013.txt | AC | 29 ms | 640 KB |
1_014.txt | AC | 29 ms | 640 KB |