Submission #85410

#TimeUsernameProblemLanguageResultExecution timeMemory
85410farukkastamonudaNice sequence (IZhO18_sequence)C++14
0 / 100
20 ms2216 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define lo long long #define inf 1000000000 #define md 1000000007 #define pb push_back #define li 400105 using namespace std; int t,n,m,B[li]; int main(){ scanf("%d",&t); while(t--){ scanf("%d %d",&n,&m);// n negative , m positive if(n==m){ printf("0\n\n"); continue; } if(n==1){ printf("%d\n",m-1); for(int i=1;i<=m-1;i++){ printf("-1 "); } printf("\n"); continue; } if(m==1){ printf("%d\n",n-1); for(int i=1;i<=n-1;i++){ printf("1 "); } printf("\n"); continue; } if(n<m){ for(int i=1;i<=400000;i++){ if(i%n==0){ B[i]=-((n-1)*10+1); } else B[i]=10; } int sum=0; for(int i=1;i<=m;i++){ sum+=B[i]; } if(sum<=0){ printf("0\n\n"); continue; } int say=m; for(int i=m+1;i<=400000;i++){ sum-=B[i-m]; sum+=B[i]; if(sum<=0) break; say++; } printf("%d\n",say); for(int i=1;i<=say;i++){ printf("%d ",B[i]); } printf("\n"); } else{ for(int i=1;i<=400000;i++){ if(i%m==0){ B[i]=((m-1)*10+1); } else B[i]=-10; } int sum=0; for(int i=1;i<=n;i++){ sum+=B[i]; } if(sum>=0){ printf("0\n\n"); continue; } int say=n; for(int i=n+1;i<=400000;i++){ sum-=B[i-n]; sum+=B[i]; if(sum<=0) break; say++; } printf("%d\n",say); for(int i=1;i<=say;i++){ printf("%d ",B[i]); } printf("\n"); } } return 0; }

Compilation message (stderr)

sequence.cpp: In function 'int main()':
sequence.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
sequence.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&m);// n negative , m positive
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...