Advertisement
hsiuyee

Problem I. \Injurious" Triples

Jun 10th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fastio ios::sync_with_stdio(false),cin.tie(0);
  5. #define pll pair<ll,ll>
  6. #define F first
  7. #define S second
  8. #define pb push_back
  9. #define ppb pop_back()
  10. #define mkp make_pair
  11. #define sz(a) (ll)a.size()
  12. #define all(x) x.begin(),x.end()
  13.  
  14. const ll MAXN=1400000;
  15. const ll INF=1e18;
  16. const ll MOD=998244353;
  17.  
  18. ll N;
  19. ll cnt[MAXN];
  20. ll arr[10010];
  21.  
  22. void init(){
  23.     cin>>N;
  24.     for(ll i=1;i<=N;i++){
  25.         cin>>arr[i];
  26.     }
  27.     for(ll i=1;i<=N;i++){
  28.         for(ll j=i+1;j<=N;j++){
  29.             ll m=arr[i]+arr[j];
  30.             if(m%2==0){
  31.                 m/=2;
  32.                 if(cnt[m]!=0){
  33.                     cout<<"Yes\n";
  34.                     cout<<i<<" "<<cnt[m]<<" "<<j<<'\n';
  35.                     return;
  36.                 }
  37.             }
  38.             cnt[arr[j]]=j;
  39.         }
  40.         for(ll j=i+1;j<=N;j++){
  41.             cnt[arr[j]]=0;
  42.         }
  43.     }
  44.     cout<<"No\n";
  45. }
  46.  
  47. void solve(){
  48.    
  49. }
  50.  
  51. signed main(){
  52.     fastio 
  53.     freopen("injurious.in","r",stdin);
  54.     freopen("injurious.out","w",stdout);
  55.     // ll T;
  56.     // cin>>T;
  57.     // while(T--){
  58.         init();
  59.         solve();
  60.     // }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement