Advertisement
PikMike

Untitled

Mar 12th, 2016
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. #define pb push_back
  5. #define pf push_front
  6. #define mp make_pair
  7. #define sz size
  8. #define ll long long
  9. #define ld long double
  10. #define fs first
  11. #define sc second
  12. #define forn(i, f, t) for(int i = f; i < t; i++)
  13. #define all(x) (x).begin(), (x).end()
  14. #define ins insert
  15.  
  16. const int INF = 2147483647;
  17. const int MOD = 1000000007;
  18. const ll INF64 = 9223372036854775807;
  19. const ld EPS = 1e-7;
  20.  
  21. using namespace std;
  22.  
  23. int gcd(int a, int b){
  24.     return (b ? gcd(b, a % b) : a);
  25. }
  26.  
  27.  
  28. int ans[1000001];
  29.  
  30. int main(){
  31.     freopen("fence.in", "r", stdin);
  32.     freopen("fence.out","w", stdout);
  33.     int n, cur = 0, k = -1, oct = 0;
  34.     scanf("%d\n", &n);
  35.     forn(i, 0, n) ans[i] = -1;
  36.     char c;
  37.     bool fl = 0, fl1 = 0;
  38.     vector<int> a;
  39.     forn(i, 0, n){
  40.         scanf("%c",  &c);
  41.         if (c == '#'){
  42.             cur++;
  43.             oct++;
  44.         }
  45.         else{
  46.             if (cur && k == -1) k = cur;
  47.             else if (cur) k = min(k, cur);
  48.             cur = 0;
  49.         }
  50.     }
  51.     if (cur && k == -1) k = cur;
  52.     else if (cur) k = min(k, cur);
  53.     if (k != -1) forn(i, 1, k + 1) ans[i * (oct / k) - 1] = (k / i + (k % i != 0) - 1);
  54.     forn(i, 0, n) printf("%d ", ans[i]); printf("\n");
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement