| Task: | Ruudukko |
| Sender: | siirikuoppala |
| Submission time: | 2017-01-19 15:00:07 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.05 s | 1 | details |
| #2 | WRONG ANSWER | 0.03 s | 1 | details |
| #3 | WRONG ANSWER | 0.04 s | 1 | details |
| #4 | WRONG ANSWER | 0.04 s | 1 | details |
| #5 | WRONG ANSWER | 0.05 s | 1 | details |
| #6 | WRONG ANSWER | 0.03 s | 1 | details |
| #7 | WRONG ANSWER | 0.05 s | 1 | details |
| #8 | WRONG ANSWER | 0.04 s | 1 | details |
| #9 | WRONG ANSWER | 0.04 s | 1 | details |
| #10 | WRONG ANSWER | 0.04 s | 2 | details |
| #11 | WRONG ANSWER | 0.04 s | 2 | details |
| #12 | WRONG ANSWER | 0.04 s | 2 | details |
| #13 | WRONG ANSWER | 0.05 s | 2 | details |
| #14 | WRONG ANSWER | 0.05 s | 2 | details |
| #15 | WRONG ANSWER | 0.03 s | 2 | details |
| #16 | WRONG ANSWER | 0.04 s | 3 | details |
| #17 | WRONG ANSWER | 0.04 s | 3 | details |
| #18 | WRONG ANSWER | 0.04 s | 3 | details |
| #19 | WRONG ANSWER | 0.05 s | 3 | details |
| #20 | WRONG ANSWER | 0.03 s | 3 | details |
| #21 | WRONG ANSWER | 0.03 s | 3 | details |
Code
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define N (1<<18)
vector<int> v[N];
ll t[N], yhh[N], hyhh[N];
int main(){
long long n; cin >> n;
ll V = n*(n-1)*(n-2)/6, x=0, x2=0, x3=0;
for(int i=1; i<=n; ++i){
int a; cin >> a;
if(yhh[a]==i) continue;
yhh[i]=a;
++x;
v[i].push_back(a);
v[a].push_back(i);
++t[i], ++t[a];
}
for(int i=1; i<=n; ++i){
int u = yhh[i];
if(u==0) continue;
--t[u], --t[i];
x2+=t[u];
x2+=t[i];
if(yhh[yhh[u]] ==i ){
++x3;
--x2;
}
yhh[i]=0;
}
//cout << x << " " << x2 << " " << x3 << "\n";
cout << V-x*(n-2)+x2 << "\n";
}
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 2 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| 0 |
Test 2
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| -2 |
Test 3
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 4 |
| correct output |
|---|
| 3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
| user output |
|---|
| -4 |
Test 4
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 5 |
| correct output |
|---|
| 2 3 4 1 1 3 4 2 1 2 4 2 3 1 3 4 3 2 1 4 5 5 5 5 5 |
| user output |
|---|
| -5 |
Test 5
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 6 |
| correct output |
|---|
| 2 3 4 5 1 1 3 4 5 2 1 2 4 5 2 3 1 3 5 2 3 4 1 4 5 4 3 2 1 5 ... |
| user output |
|---|
| -4 |
Test 6
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 7 |
| correct output |
|---|
| 2 3 4 5 6 1 1 3 4 5 6 2 1 2 4 5 6 2 3 1 3 5 6 2 3 4 1 4 6 2 3 4 5 1 5 ... |
| user output |
|---|
| 0 |
Test 7
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 8 |
| correct output |
|---|
| 2 3 4 5 6 7 1 1 3 4 5 6 7 2 1 2 4 5 6 7 2 3 1 3 5 6 7 2 3 4 1 4 6 7 2 3 4 5 1 5 ... |
| user output |
|---|
| 8 |
Test 8
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 9 |
| correct output |
|---|
| 2 3 4 5 6 7 8 1 1 3 4 5 6 7 8 2 1 2 4 5 6 7 8 2 3 1 3 5 6 7 8 2 3 4 1 4 6 7 8 2 3 4 5 1 5 ... |
| user output |
|---|
| 21 |
Test 9
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 1 1 3 4 5 6 7 8 9 2 1 2 4 5 6 7 8 9 2 3 1 3 5 6 7 8 9 2 3 4 1 4 6 7 8 9 2 3 4 5 1 5 ... |
| user output |
|---|
| 40 |
Test 10
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| -2 |
Test 11
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 4 |
| correct output |
|---|
| 3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
| user output |
|---|
| -4 |
Test 12
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 29 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 2871 |
Test 13
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 48 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 15088 |
Test 14
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 80 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 75920 |
Test 15
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 97 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 138225 |
Test 16
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 3 |
| correct output |
|---|
| QAQ |
| user output |
|---|
| -2 |
Test 17
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 4 |
| correct output |
|---|
| 3 4 3 4 3 1 1 2 4 4 3 2 2 2 1 1 |
| user output |
|---|
| -4 |
Test 18
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 111 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 209716 |
Test 19
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 506 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 21209496 |
Test 20
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 844 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 99135396 |
Test 21
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 991 |
| correct output |
|---|
| 2 3 4 5 6 7 8 9 10 11 12 13 14... |
| user output |
|---|
| 160736236 |
