Submission #67933

# Submission time Handle Problem Language Result Execution time Memory
67933 2018-08-15T14:49:06 Z yusufake Binary Subsequences (info1cup17_binary) C++
82 / 100
900 ms 580 KB
#include<bits/stdc++.h> 
using namespace std; 

#define pb push_back
#define mp make_pair
#define st first
#define nd second

typedef long long ll; 
typedef pair < int , int > pp; 
const int mod = 1e9 + 7; 
const int N   = 2e6 + 6; 

pair < int , pp > ans;

int f(int x, int y){
    if(x < y) swap(x,y); 
    int a=x; int b=y;
    int t;
    int zz=0;
    for(; y ;){
        t = x%y;
        zz += x/y;
        x = y;
        y = t;
    }
    if(x==1)
        ans = min(ans , mp(zz,mp(a,b)));
    return x == 1;
}

int ww,k,t,i,x,y,zz,h;
int main(){
    scanf("%d",&ww);
    for(;ww--; puts("")){
        scanf("%d",&k);
        k += 2;
        t = 0;
        ans.st = mod;
        for(i=1;i<k;i++){
            t += f(i,k-i);
        }
        printf("%d\n",t);
        x = ans.nd.st;
        y = ans.nd.nd;
        for(; y ; h=!h){
        t = x%y;
        zz = x/y;
        if(!t) zz--;
        for(;zz--;) printf("%d ",h);
        x = y;
        y = t;
    }
    
    }
    return 0;
}    

Compilation message

binary.cpp: In function 'int main()':
binary.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ww);
     ~~~~~^~~~~~~~~~
binary.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 154 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 484 KB Output is correct
2 Correct 120 ms 580 KB Output is correct
3 Correct 117 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 580 KB Time limit exceeded
2 Halted 0 ms 0 KB -