이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |