Submission #891291
Source Code Expand
/* 문제 2015. */ #include <stdio.h> #include <cmath> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <functional> #include <cstring> #include <string> #include <map> #include <set> #include <iostream> #include <ctime> #define enp printf("**Entry Point**\n") #define A first #define B second #define MP make_pair using namespace std; typedef long long ll; const int INF = 0x6fffffff; const int MINF = 0x80000000; const int mod = 1000000007; const int cons = 100001; const double pi = 3.141592653589793; int a[100001]; bool chk[100001]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } int ans = 0; for (int i = 1; i <= n; i++) { if (chk[i])continue; if (i == a[a[i]]) { ans++; chk[i] = true; chk[a[i]] = true; } } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - CODEFESTIVAL 2016 |
User | softgoorm |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 934 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:42:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:46:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 2 ms | 256 KB |
0_01.txt | WA | 2 ms | 256 KB |
0_02.txt | WA | 2 ms | 256 KB |
1_00.txt | WA | 2 ms | 256 KB |
1_01.txt | WA | 2 ms | 256 KB |
1_02.txt | WA | 2 ms | 256 KB |