Advertisement
SAMonna

I - Train Tracks

Jan 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 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, 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. if(result == 1){
  29. cout << "LOOP" << endl;
  30. } else {
  31. cout << "NO LOOP" << endl;
  32. }
  33. }
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement