CODE FESTIVAL 2016 qual A

Submission #1152716

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int,int>pii;

const int maxn=1e5+55;
int a;
int main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	int n;
	cin>>n;
	// map<int,set<int> >mpp;
	for(int i=1 ; i<=n ; i++) {
		cin>>a;

		mpp[i].insert(a);
	}
	int cnt=0;
	for(map<int,int>::iterator it=mpp.begin() ; it!=mpp.end() ; it++) {
		int u=it->ff;
		for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
			int v=*it2;
			if(mpp[v].find(u)!=mpp.end()) {	
				++cnt;
				mpp[v].erase(u);
				break;
			}
		} 
		mpp[u].erase(v);
	}
	
	/*for (int i=1 ; i<=n ; i++) {
		if(a[a[i]]==i)
			cnt++;
	}*/
	cnt/=2;
	cout<<cnt<<endl;
}

Submission

Task問題 B - 仲良しうさぎ / Friendly Rabbits
User nameユーザ名 killjee
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 CE
Score得点 -
Source lengthソースコード長 822 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:3: error: ‘mpp’ was not declared in this scope
mpp[i].insert(a);
^
./Main.cpp:25:32: error: ‘mpp’ was not declared in this scope
for(map<int,int>::iterator it=mpp.begin() ; it!=mpp.end() ; it++) {
^
./Main.cpp:27:37: error: request for member ‘begin’ in ‘it.std::_Rb_tree_iterator<_Tp>::operator-><std::pair<const int, int> >()->std::pair<const int, int>::second’, which is of non-class type ‘int’
for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
^
./Main.cpp:27:59: error: request for member ‘end’ in ‘it.std::_Rb_tree_iterator<_Tp>::operator-><std::pair<const int, int> >()->std::pair<const int, int>::second’, which is of non-class type ‘int’
for(set<int>::iterator it2=it->ss.begin() ; it2!=it->ss.end() ; it2++) {
^
./Main.cpp:35:16: error: ‘v’ was not declared in this scope
mpp[u].erase(v);
...

Test case