Submission #5440591


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, a, res = 0;
    string s;
    in(n);
    map<int, vector<int>> m;
    rep(i, 1, n + 1){
        in(a);
        m[a].pb(i);
    }
    rep(i, 1, n + 1){
        each(j, m[i]){
            if(find(all(m[j]), i) != m[j].end()){
                res++;
            }
        }
    }
    print(res / 2);
}

Submission Info

Submission Time
Task B - Friendly Rabbits
User Regent_50m
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1763 Byte
Status AC
Exec Time 123 ms
Memory 11264 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 15
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 2 ms 384 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 119 ms 11264 KB
1_02.txt AC 119 ms 11264 KB
1_03.txt AC 123 ms 10240 KB
1_04.txt AC 119 ms 10240 KB
1_05.txt AC 119 ms 10240 KB
1_06.txt AC 120 ms 10240 KB
1_07.txt AC 123 ms 10240 KB
1_08.txt AC 36 ms 3968 KB
1_09.txt AC 92 ms 8448 KB
1_10.txt AC 77 ms 7168 KB
1_11.txt AC 15 ms 1920 KB