Guest User

week16- A1. Apple Pen Easy, Author Solution

a guest
Dec 9th, 2016
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int SIZE = 101;
  4. string s[SIZE],T;
  5. int main(){
  6.     ios_base::sync_with_stdio(false);
  7.     int n;
  8.     cin>>n;
  9.     for(int i=1;i<=n;i++)cin>>s[i];
  10.     cin>>T;
  11.     vector<pair<int,int> >an;
  12.     for(int i=1;i<=n;i++)
  13.         for(int j=i+1;j<=n;j++){
  14.             if(s[i]+s[j]==T||s[j]+s[i]==T)an.push_back(make_pair(i,j));
  15.         }
  16.     printf("%d\n",(int)an.size());
  17.     for(int i=0;i<an.size();i++)printf("%d %d\n",an[i].first,an[i].second);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment