Submission #41088

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
410882018-02-12 15:09:13kriiiSnake Escaping (JOI18_snake_escaping)C++14
100 / 100
865 ms21960 KiB
#include <stdio.h>
int L,Q;
char sc[1<<20+2]; int bc[1<<20];
int Z[1<<20],O[1<<20];
void go(int l, int r)
{
if (l+1 == r) return;
int m = (l + r) / 2;
go(l,m);
go(m,r);
for (int i=l;i<m;i++){
Z[i-l+m] += Z[i];
O[i] += O[i-l+m];
}
}
int main()
{
scanf ("%d %d",&L,&Q);
scanf ("%s",sc);
for (int i=0;i<(1<<L);i++){
if (i) bc[i] = bc[i-(i&(-i))] + 1;
Z[i] = O[i] = sc[i] - '0';
}
go(0,(1<<L));
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

snake_escaping.cpp:4:10: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
 char sc[1<<20+2]; int bc[1<<20];
          ^
snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d",&L,&Q);
                       ^
snake_escaping.cpp:23:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%s",sc);
                 ^
snake_escaping.cpp:32:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char q[22]; scanf ("%s",q);
                             ^
#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...