Submission #90382

# Submission time Handle Problem Language Result Execution time Memory
90382 2018-12-21T12:40:01 Z Nordway Gift (IZhO18_nicegift) C++14
0 / 100
6 ms 3752 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 1e18;
const ll inf = 1e9;
const int mod = 998244353;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 2e5+5;
const int M = 1e5+1;

pii a[N];

int main(){
	int n,k;
	cin>>n>>k;
	int m=n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x;
		a[i].y=i;
	}
	sort(a+1,a+n+1);
	int l=1,r=2;
	vector< pair<int,pii> >ans;
	bool w=0;
	while(1){
		if(l==n){
			w=1;
			break;
		}
		if(l>n)break;
		int val=a[l].x;
		ans.pb(mp(val,mp(a[l].y,a[r].y)));
		l++;
		if(a[r].x==val)r+=2,l++;
		else r++;
	}
	if(w)cout<<"-1";
	else{
		cout<<sz(ans)<<endl;
		for(int i=0;i<sz(ans);i++){
			cout<<ans[i].x<<" "<<ans[i].y.x<<" "<<ans[i].y.y<<endl;
		}
	}
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:34:6: warning: unused variable 'm' [-Wunused-variable]
  int m=n;
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n=4
2 Incorrect 2 ms 512 KB Jury has the answer but participant has not
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n=4
2 Incorrect 2 ms 512 KB Jury has the answer but participant has not
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n=4
2 Incorrect 2 ms 512 KB Jury has the answer but participant has not
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 3752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB n=4
2 Incorrect 2 ms 512 KB Jury has the answer but participant has not
3 Halted 0 ms 0 KB -