제출 #206379

#제출 시각아이디문제언어결과실행 시간메모리
206379Ruxandra985Devil's Share (RMI19_devil)C++14
14 / 100
176 ms2172 KiB
#include <bits/stdc++.h> using namespace std; int n; int f[10] , f2[10] , sol[1000000]; int possible (int nr){ int i , p , maxi , scz; for (i = 1 ; i <= 9 ; i++) f2[i] = f[i]; if (nr % 10 > nr / 10){ /// ar trb ca nr % 10 sa apara o sg data si la sf sol[n] = nr % 10; f2[nr % 10]--; /// daca nr / 10 nu e maxim nu se poate for (i = nr / 10 + 1 ; i <= 9 ; i++) if (f2[i]) return 0; /// now what p = 0; for (i = 1 ; i <= 9; i++){ while (f2[i]){ /// le pui cresc si e ok sol[++p] = i; f2[i]--; } } return 1; } else { /// n % 10 <= n / 10 for (i = 1 ; i <= 9 ; i++) if (f2[i]) maxi = i; p = n + 2; scz = 0; if (maxi > nr / 10){ /// ai grija if (f2[maxi] != 1) return 0; f2[maxi] = 0; sol[n] = maxi; for (i = nr / 10 + 1 ; i <= 9 ; i++) if (f2[i]) return 0; /// acum n / 10 = maxi /// pot sa pun orice dar sa nu am n/10 pe n-1? i = nr % 10; if (f2[i]){ /// pun o val cat mai mare sol[n - 1] = i; f2[i]--; } p = n; scz = 2; } int add = -2; for (i = 9 ; i ; i--){ while (f2[i]){ /// le pui cresc si e ok if (p + add <= 0){ /// acum add e -2 add = 2; if (p == 2) p = 1 - add; else p = 2 - add; } sol[p + add] = i; p += add; f2[i]--; } } return 1; } } int main() { FILE *fin = stdin; FILE *fout = stdout; int t , k , i; fscanf (fin,"%d",&t); for (;t;t--){ fscanf (fin,"%d",&k); n = 0; for (i=1;i<=9;i++){ fscanf (fin,"%d",&f[i]); n += f[i]; } if (k == 2){ /// subtask 14p for (i = 11 ; i <= 99 ; i++){ if (i % 10 != 0 && f[i % 10] && f[i / 10]){ if (possible(i)) break; } } for (i = 1 ; i <= n ; i++) fprintf (fout,"%d",sol[i]); fprintf (fout,"\n"); } } return 0; }

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

devil.cpp: In function 'int possible(int)':
devil.cpp:7:24: warning: variable 'scz' set but not used [-Wunused-but-set-variable]
     int i , p , maxi , scz;
                        ^~~
devil.cpp: In function 'int main()':
devil.cpp:92:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&t);
     ~~~~~~~^~~~~~~~~~~~~
devil.cpp:94:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&k);
         ~~~~~~~^~~~~~~~~~~~~
devil.cpp:97:20: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             fscanf (fin,"%d",&f[i]);
             ~~~~~~~^~~~~~~~~~~~~~~~
devil.cpp: In function 'int possible(int)':
devil.cpp:43:9: warning: 'maxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (maxi > nr / 10){ /// ai grija
         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...