Submission #206377

#TimeUsernameProblemLanguageResultExecution timeMemory
206377Ruxandra985Devil's Share (RMI19_devil)C++14
0 / 100
147 ms2168 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; //if (nr == 31) // printf ("a"); 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; } for (i = 9 ; i ; i--){ while (f2[i]){ /// le pui cresc si e ok if (p - 2 <= 0) p = n + 1 - scz; sol[p - 2] = i; p -= 2; 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; }

Compilation message (stderr)

devil.cpp: In function 'int main()':
devil.cpp:88: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:90: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:93: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:46: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...