Submission #67089

#TimeUsernameProblemLanguageResultExecution timeMemory
67089osmanorhanDEL13 (info1cup18_del13)C++17
0 / 100
10 ms1096 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <cmath> #include <climits> #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <cassert> #include <vector> #define all(x) x.begin() , x.end() #define fi first #define se second #define pb push_back #define umax( x , y ) x = max( x , (y) ) #define umin( x , y ) x = min( x , (y) ) #define For( i , a ) for(int i=1;i<=a;i++) #define ort (b+s)/2 #define y2 asrwjaelkf #define y1 asseopirwjaelkf #define set multiset using namespace std; typedef long long Lint; typedef double db; typedef pair<int,int> ii; typedef pair<int,char> ic; typedef pair<db,db> dd; typedef pair<int,ii> iii; typedef pair<ii,ii> i4; const int maxn = 100020; const int maxm = 1000020; const int MOd = 998244353; int a, b; int ar[maxn], loc[maxn]; int dn[maxn][3], go[maxn][3]; bool f( int n, int x ) { if( n == a+2 ) { if( x == 0 ) return 1; return 0; } int &ret = dn[n][x]; if( ret != -1 ) return ret; ret = 0; if( ar[n] < x ) return ret; if( ar[n] < 3 ) { if( f( n+1, ar[n]-x ) ) { go[n][x] = ar[n]-x; return ret = 1; } return ret = 0; } if( x != 0 && ar[n] >= x && (ar[n]-x)%2 == 0 && f( n+1, 0 ) ) { go[n][x] = 0; return ret = 1; } if( ar[n] >= x+1 && (ar[n]-(x+1))%2 == 0 && f( n+1, 1 ) ) { go[n][x] = 1; return ret = 1; } if( ar[n] >= x+2 && (ar[n]-(x+2))%2 == 0 && f( n+1, 1 ) ) { go[n][x] = 2; return ret = 1; } return ret = 0; } void solve( ) { scanf("%d %d",&b,&a); for(int i=1;i<=a;i++) scanf("%d",&loc[i]); sort( loc+1, loc+1+a ); loc[a+1] = b+1; loc[0] = 0; for(int i=1;i<=a+1;i++) { ar[i] = loc[i]-loc[i-1] - 1; //printf("----- %d\n",ar[i]); } for(int i=0;i<=a+2;i++) dn[i][0] = dn[i][1] = dn[i][2] = -1; if( f( 1, 0 ) ) { printf("%d\n",(b-a)/2); int n = 1, x = 0; vector<int> last; while( n < a+2 ) { int h = ar[n] - x - go[n][x]; int l = loc[n-1] + 2; assert( h % 2 == 0 ); while( h > 0 ) { printf("%d ",l); h -= 2; l += 2; } h += go[n][x]; while( h ) { last.pb( loc[n] ); h--; } x = go[n][x]; n++; } for(int i=0;i<last.size();i++) printf("%d ",last[i]); printf("\n"); } else printf("-1\n"); } int main() { //freopen("asd.in","r",stdin); //freopen("output17.txt","w",stdout); int n; scanf("%d",&n); while( n-- ) solve(); return 0; }

Compilation message (stderr)

del13.cpp: In function 'bool f(int, int)':
del13.cpp:57:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    return ret = 1;
           ~~~~^~~
del13.cpp:59:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   return ret = 0;
          ~~~~^~~
del13.cpp:63:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   return ret = 1;
          ~~~~^~~
del13.cpp:67:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   return ret = 1;
          ~~~~^~~
del13.cpp:71:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   return ret = 1;
          ~~~~^~~
del13.cpp:73:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  return ret = 0;
         ~~~~^~~
del13.cpp: In function 'void solve()':
del13.cpp:111:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<last.size();i++) printf("%d ",last[i]);
               ~^~~~~~~~~~~~
del13.cpp:78:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&b,&a);
  ~~~~~^~~~~~~~~~~~~~~
del13.cpp:79:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=a;i++) scanf("%d",&loc[i]);
                        ~~~~~^~~~~~~~~~~~~~
del13.cpp: In function 'int main()':
del13.cpp:122:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
#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...