Submission #1674573
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <functional> #include <numeric> #include <iomanip> #define fi first #define se second #define fcout(n) cout<<fixed<<setprecision((n)) #define cinl(str) getline(cin,(str)) using namespace std; bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;} typedef pair<int,int> pii; typedef long long ll; typedef vector<int> vi; typedef vector<long long > vll; typedef vector< vi > vvi; double pie=acos(-1); int INF=1000000007; int dx[4] = { 0,-1,0,1 }; int dy[4] = { -1,0,1,0 }; int main() { int n; int ans=0; cin>>n; vi a(n+1); a[0]=0; for(int i=1;i<=n;i++){ cin>>a[i]; //cout<<a[i]<<endl; } for(int i=1;i<=n;i++){ if(i==a[a[i]]){ ans++; } } ans/=2; cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | Cytus |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 930 Byte |
Status | AC |
Exec Time | 29 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 29 ms | 640 KB |
1_02.txt | AC | 29 ms | 640 KB |
1_03.txt | AC | 29 ms | 640 KB |
1_04.txt | AC | 29 ms | 640 KB |
1_05.txt | AC | 29 ms | 640 KB |
1_06.txt | AC | 29 ms | 640 KB |
1_07.txt | AC | 29 ms | 640 KB |
1_08.txt | AC | 11 ms | 384 KB |
1_09.txt | AC | 24 ms | 512 KB |
1_10.txt | AC | 22 ms | 512 KB |
1_11.txt | AC | 5 ms | 256 KB |