CSES - BAPC 2015 - Results
Submission details
Task:Physical Music
Sender:KnowYourArchitecture
Submission time:2017-10-17 20:58:55 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.23 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:28:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<res.size();++i)cout<<res[i]<<'\n';
                          ^

Code

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;

int main(){
	int Tn;
	cin>>Tn;
	while(Tn--){
		int n;
		cin >> n;
		vector<int> single(n);
		vector<int> download(n);
		for (int i = 0; i < n; i++) {
			int a;
			cin >> a;
			single[i] = i+1;
			download[a-1] = i+1;
		}

		vector<int> res;
		for (int i = 0; i < n; i++) {
			if (download[i] > i+1)res.emplace_back(download[i]);
		}
		sort(res.begin(),res.end());
		cout<<res.size()<<'\n';
		for(int i=0;i<res.size();++i)cout<<res[i]<<'\n';
	}
}

/*
single		download
1		3
2		4
3		2
4		1
*/

Test details

Test 1

Verdict:

input
20
3
1
2
3
...

correct output
0
2
3
4
3
...

user output
0
2
3
4
2
...