Advertisement
SAMonna

I - Train Tracks

Jan 20th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdlib.h>
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. int main(){
  7. int t, length, i, female, male, n, j, k, result;
  8. string str;
  9.  
  10. scanf("%d ", &t);
  11.  
  12. while(t--){
  13. getline(cin, str);
  14. length = str.size();
  15. result = 0;
  16.  
  17. if(length >= 5){
  18. for(i = 1; i <= length - 2; i+=3){
  19. if(str[i] != str[i + 2]){
  20. result = 1;
  21. } else {
  22. result = 0;
  23. break;
  24. }
  25. }
  26. }
  27.  
  28.  
  29. if(result == 1){
  30. cout << "LOOP" << endl;
  31. } else {
  32. cout << "NO LOOP" << endl;
  33. }
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement