提出 #893173
ソースコード 拡げる
#include <algorithm>
#include <cstdio>
#include <vector>
#include <valarray>
#include <queue>
#include <iostream>
#include <numeric>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = (a); i >= (b); --i)
#define rREP(i, n) rFOR(i, n-1, 0)
#define AND &&
#define OR ||
#define IN(x, min, max) (min <= x AND x < max)
#define VEC(type) vector<type>
#define DVEC(type) vector<vector<type>>
#define VAL(type) valarray<type>
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#define HOGE printf("%s\n", "hoge");
#define DUMP(p) cout << p << endl;
const int INF = 2323232323;
using namespace std;
typedef pair<int, int> P;
int N;
int main(){
scanf("%d", &N);
VEC(int) a(N);
REP(i, N){
scanf(" %d", &a[i]);
}
VEC(int) dp(N, -1);
int ans = 0;
REP(i, N){
if (dp[i] > 0) {
continue;
}
if (i+1 == a[a[i]-1]) {
ans++;
dp[a[i]-1] = 1;
}
}
printf("%d\n", ans);
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
B - 仲良しうさぎ |
| ユーザ |
rarilurelo |
| 言語 |
C++14 (GCC 5.4.1) |
| 得点 |
200 |
| コード長 |
1095 Byte |
| 結果 |
AC |
| 実行時間 |
13 ms |
| メモリ |
1024 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
./Main.cpp:30:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d", &a[i]);
^
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
200 / 200 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 0_00.txt |
AC |
3 ms |
256 KiB |
| 0_01.txt |
AC |
3 ms |
256 KiB |
| 0_02.txt |
AC |
3 ms |
384 KiB |
| 1_00.txt |
AC |
3 ms |
256 KiB |
| 1_01.txt |
AC |
13 ms |
1024 KiB |
| 1_02.txt |
AC |
13 ms |
1024 KiB |
| 1_03.txt |
AC |
13 ms |
1024 KiB |
| 1_04.txt |
AC |
13 ms |
1024 KiB |
| 1_05.txt |
AC |
13 ms |
1024 KiB |
| 1_06.txt |
AC |
13 ms |
1024 KiB |
| 1_07.txt |
AC |
13 ms |
1024 KiB |
| 1_08.txt |
AC |
7 ms |
512 KiB |
| 1_09.txt |
AC |
11 ms |
896 KiB |
| 1_10.txt |
AC |
10 ms |
768 KiB |
| 1_11.txt |
AC |
4 ms |
384 KiB |