Advertisement
facug91

Untitled

Oct 18th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. /*
  2.     By: facug91
  3.     From: http://coj.uci.cu/24h/problem.xhtml?abb=1240
  4.     Name: Bingo!
  5.     Number: 1240
  6.     Date: 08/11/2013
  7. */
  8.  
  9. #include <iostream>
  10. #include <cstdio>
  11. #include <string>
  12. #include <cstring>
  13. #include <list>
  14. #include <iterator>
  15. #include <cstdlib>
  16. #include <set>
  17.  
  18. using namespace std;
  19.  
  20. int main () {
  21.    
  22.     int n, b, aux, act;
  23.     list<int> sobrantes;
  24.     set<int> total;
  25.     list<int>::iterator itr;
  26.    
  27.     cin>>n>>b;
  28.    
  29.    
  30.     while ((n) && (b)) {
  31.         for (;b--;) {
  32.             cin>>aux;
  33.             sobrantes.push_back(aux);
  34.         }
  35.        
  36.         b = sobrantes.size();
  37.         for (;b--;) {
  38.             act = sobrantes.front();
  39.             for (itr = sobrantes.begin(); itr != sobrantes.end(); itr++) {
  40.                 total.insert(abs(act - *itr));
  41.             }
  42.             sobrantes.pop_front();
  43.         }
  44.        
  45.         if (total.size() == n+1) {
  46.             printf("Y\n");
  47.         } else {
  48.             printf("N\n");
  49.         }
  50.        
  51.         total.clear();
  52.        
  53.         cin>>n>>b;
  54.     }
  55.    
  56.    
  57.    
  58.    
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement