Submission #7141784
Source Code Expand
#include <bits/stdc++.h> const int MOD = 1000000007; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define copy(from, to) copy(from.begin(), from.end(), back_inserter(to)) #define sort(a) sort(a.begin(), a.end()) #define reverse(s) reverse(s.begin(), s.end()) #define p(s) cout << (s) << endl typedef long long ll; using namespace std; template<class T> void load(vector<T> &v, int n) { for (int i = 0; i < n; ++i) { T t; cin >> t; v.push_back(t); } } template<class T> T max(vector<T> &v) { return *max_element(v.begin(), v.end()); } template<class T> T min(vector<T> &v) { return *min_element(v.begin(), v.end()); } void py(bool isUpper = false) { if (isUpper) { p("YES"); } else { p("Yes"); } } void pn(bool isUpper = false) { if (isUpper) { p("NO"); } else { p("No"); } } int main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; ++i) { cin >> a[i]; } int c = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (i == a[j] && a[i] == j) c++; } } //ダブルカウントしているので半分にする p(c / 2); }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | karayuu |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1212 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | TLE | 2103 ms | 640 KB |
1_02.txt | TLE | 2103 ms | 640 KB |
1_03.txt | TLE | 2103 ms | 640 KB |
1_04.txt | TLE | 2103 ms | 640 KB |
1_05.txt | TLE | 2103 ms | 640 KB |
1_06.txt | TLE | 2103 ms | 640 KB |
1_07.txt | TLE | 2103 ms | 640 KB |
1_08.txt | AC | 932 ms | 384 KB |
1_09.txt | TLE | 2103 ms | 512 KB |
1_10.txt | TLE | 2103 ms | 512 KB |
1_11.txt | AC | 186 ms | 256 KB |