제출 #385599

#제출 시각아이디문제언어결과실행 시간메모리
385599patrikpavic2Nice sequence (IZhO18_sequence)C++17
76 / 100
2056 ms47904 KiB
#include <cstdio> #include <cstring> #define PB push_back using namespace std; const int N = 4e5 + 500; int bio[N], L[N], R[N]; void clean(){ memset(bio, 0, sizeof(bio)); memset(L, -1, sizeof(L)); memset(R, -1, sizeof(R)); } bool ima_ciklus(int x){ if(bio[x]) return bio[x] == 1; bio[x] = 1; if(L[x] != -1 && ima_ciklus(L[x])) return 1; if(R[x] != -1 && ima_ciklus(R[x])) return 1; bio[x] = 2; return 0; } int P[N], cur = 0; void topsort(int x){ if(bio[x]) return; bio[x] = 1; if(L[x] != -1) topsort(L[x]); if(R[x] != -1) topsort(R[x]); P[x] = cur++; } bool check(int n, int a, int b, bool napravi = false){ clean(); for(int i = 0;i <= n;i++){ if(i + a <= n) L[i + a] = i; if(i + b <= n) R[i] = i + b; } if(!napravi){ for(int i = 0;i <= n;i++) if(ima_ciklus(i)){ return false; } return true; } cur = 0; for(int i = 0;i <= n;i++) topsort(i); for(int i = 1;i <= n;i++) P[i] -= P[0]; P[0] = 0; printf("%d\n", n); for(int i = 1;i <= n;i++) printf("%d ", P[i] - P[i - 1]); printf("\n"); return true; } int main(){ int T; scanf("%d", &T); for(;T--;){ int a, b; scanf("%d%d", &b, &a); int ans = 0; for(int i = 18;i >= 0;i--){ if(ans + (1 << i) <= a + b && check(ans + (1 << i), a, b)) ans += (1 << i); } check(ans, a, b, 1); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

sequence.cpp: In function 'int main()':
sequence.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |  int T; scanf("%d", &T);
      |         ~~~~~^~~~~~~~~~
sequence.cpp:67:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   67 |   int a, b; scanf("%d%d", &b, &a);
      |             ~~~~~^~~~~~~~~~~~~~~~
#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...