Submission #825735

# Submission time Handle Problem Language Result Execution time Memory
825735 2023-08-15T07:31:56 Z Amylopectin Digital Circuit (IOI22_circuit) C++17
18 / 100
3000 ms 98112 KB
#include "circuit.h"
#include <stdio.h>
#include <vector>
using namespace std;
const long long mxn = 2e6 + 10,mo = 1000002022;
vector<long long> pat[mxn] = {},fa[mxn] = {};
long long n,m,dp[mxn][2] = {};
long long re(long long cn)
{
  long long i,j,k,fn,cva;
  if(cn >= n)
  {
    return 0;
  }
  fa[cn].clear();
  fa[cn].push_back(1);
  for(i=1; i<=pat[cn].size(); i++)
  {
    fa[cn].push_back(0);
  }
  for(i=0; i<pat[cn].size(); i++)
  {
    fn = pat[cn][i];
    re(fn);
    for(j=pat[cn].size(); j>=0; j--)
    {
      cva = 0;
      for(k=0; k<2; k++)
      {
        if(j-k < 0)
        {
          break;
        }
        cva += dp[fn][k] * fa[cn][j-k];
        cva %= mo;
      }
      fa[cn][j] = cva;
    }
  }
  dp[cn][0] = 0;
  dp[cn][1] = 0;
  for(i=0; i<=pat[cn].size(); i++)
  {
    dp[cn][0] += fa[cn][i] * (pat[cn].size() - i);
    dp[cn][1] += fa[cn][i] * i;
    dp[cn][0] %= mo;
    dp[cn][1] %= mo;
  }
  return 0;
}
void init(int N, int M, std::vector<int> pp, std::vector<int> aa) 
{
  long long i,j,cn,cm,fn,fm;
  n = N;
  m = M;
  for(i=0; i<n+m; i++)
  {
    pat[pp[i]].push_back(i);
  }
  for(i=0; i<m; i++)
  {
    if(aa[i] == 0)
    {
      dp[n+i][0] = 1;
    }
    else 
    {
      dp[n+i][1] = 1;
    }
    
  }

  return ;
}

int count_ways(int l, int r) 
{
  long long i,j,cn,cm,fn,fm;
  int ret;
  for(i=l; i<=r; i++)
  {
    if(dp[i][1] == 0)
    {
      dp[i][0] = 0;
      dp[i][1] = 1;
    }
    else 
    {
      dp[i][0] = 1;
      dp[i][1] = 0;
    }
  }
  re(0);
  ret = dp[0][1];
  return ret;
}

Compilation message

circuit.cpp: In function 'long long int re(long long int)':
circuit.cpp:17:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(i=1; i<=pat[cn].size(); i++)
      |            ~^~~~~~~~~~~~~~~~
circuit.cpp:21:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(i=0; i<pat[cn].size(); i++)
      |            ~^~~~~~~~~~~~~~~
circuit.cpp:42:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(i=0; i<=pat[cn].size(); i++)
      |            ~^~~~~~~~~~~~~~~~
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:53:15: warning: unused variable 'j' [-Wunused-variable]
   53 |   long long i,j,cn,cm,fn,fm;
      |               ^
circuit.cpp:53:17: warning: unused variable 'cn' [-Wunused-variable]
   53 |   long long i,j,cn,cm,fn,fm;
      |                 ^~
circuit.cpp:53:20: warning: unused variable 'cm' [-Wunused-variable]
   53 |   long long i,j,cn,cm,fn,fm;
      |                    ^~
circuit.cpp:53:23: warning: unused variable 'fn' [-Wunused-variable]
   53 |   long long i,j,cn,cm,fn,fm;
      |                       ^~
circuit.cpp:53:26: warning: unused variable 'fm' [-Wunused-variable]
   53 |   long long i,j,cn,cm,fn,fm;
      |                          ^~
circuit.cpp: In function 'int count_ways(int, int)':
circuit.cpp:78:15: warning: unused variable 'j' [-Wunused-variable]
   78 |   long long i,j,cn,cm,fn,fm;
      |               ^
circuit.cpp:78:17: warning: unused variable 'cn' [-Wunused-variable]
   78 |   long long i,j,cn,cm,fn,fm;
      |                 ^~
circuit.cpp:78:20: warning: unused variable 'cm' [-Wunused-variable]
   78 |   long long i,j,cn,cm,fn,fm;
      |                    ^~
circuit.cpp:78:23: warning: unused variable 'fn' [-Wunused-variable]
   78 |   long long i,j,cn,cm,fn,fm;
      |                       ^~
circuit.cpp:78:26: warning: unused variable 'fm' [-Wunused-variable]
   78 |   long long i,j,cn,cm,fn,fm;
      |                          ^~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94140 KB Output is correct
2 Correct 44 ms 94164 KB Output is correct
3 Correct 58 ms 94152 KB Output is correct
4 Correct 58 ms 94152 KB Output is correct
5 Correct 56 ms 94236 KB Output is correct
6 Correct 54 ms 94176 KB Output is correct
7 Correct 55 ms 94212 KB Output is correct
8 Correct 57 ms 94260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 94104 KB Output is correct
2 Correct 44 ms 94144 KB Output is correct
3 Correct 47 ms 94304 KB Output is correct
4 Correct 47 ms 94152 KB Output is correct
5 Correct 53 ms 94184 KB Output is correct
6 Correct 53 ms 94260 KB Output is correct
7 Correct 46 ms 94280 KB Output is correct
8 Correct 46 ms 94284 KB Output is correct
9 Correct 46 ms 94252 KB Output is correct
10 Correct 46 ms 94400 KB Output is correct
11 Correct 49 ms 94328 KB Output is correct
12 Correct 46 ms 94300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94140 KB Output is correct
2 Correct 44 ms 94164 KB Output is correct
3 Correct 58 ms 94152 KB Output is correct
4 Correct 58 ms 94152 KB Output is correct
5 Correct 56 ms 94236 KB Output is correct
6 Correct 54 ms 94176 KB Output is correct
7 Correct 55 ms 94212 KB Output is correct
8 Correct 57 ms 94260 KB Output is correct
9 Correct 44 ms 94104 KB Output is correct
10 Correct 44 ms 94144 KB Output is correct
11 Correct 47 ms 94304 KB Output is correct
12 Correct 47 ms 94152 KB Output is correct
13 Correct 53 ms 94184 KB Output is correct
14 Correct 53 ms 94260 KB Output is correct
15 Correct 46 ms 94280 KB Output is correct
16 Correct 46 ms 94284 KB Output is correct
17 Correct 46 ms 94252 KB Output is correct
18 Correct 46 ms 94400 KB Output is correct
19 Correct 49 ms 94328 KB Output is correct
20 Correct 46 ms 94300 KB Output is correct
21 Correct 46 ms 94220 KB Output is correct
22 Correct 45 ms 94264 KB Output is correct
23 Correct 45 ms 94152 KB Output is correct
24 Correct 46 ms 94264 KB Output is correct
25 Correct 50 ms 94308 KB Output is correct
26 Correct 54 ms 94248 KB Output is correct
27 Correct 52 ms 94316 KB Output is correct
28 Correct 49 ms 94296 KB Output is correct
29 Correct 57 ms 94164 KB Output is correct
30 Correct 58 ms 94152 KB Output is correct
31 Correct 46 ms 94388 KB Output is correct
32 Correct 46 ms 94312 KB Output is correct
33 Correct 49 ms 94212 KB Output is correct
34 Correct 46 ms 94192 KB Output is correct
35 Correct 48 ms 94180 KB Output is correct
36 Correct 45 ms 94408 KB Output is correct
37 Correct 58 ms 94408 KB Output is correct
38 Correct 57 ms 94424 KB Output is correct
39 Correct 45 ms 94172 KB Output is correct
40 Correct 46 ms 94228 KB Output is correct
41 Correct 50 ms 94276 KB Output is correct
42 Correct 47 ms 94152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3092 ms 98112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3092 ms 98112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 94104 KB Output is correct
2 Correct 44 ms 94144 KB Output is correct
3 Correct 47 ms 94304 KB Output is correct
4 Correct 47 ms 94152 KB Output is correct
5 Correct 53 ms 94184 KB Output is correct
6 Correct 53 ms 94260 KB Output is correct
7 Correct 46 ms 94280 KB Output is correct
8 Correct 46 ms 94284 KB Output is correct
9 Correct 46 ms 94252 KB Output is correct
10 Correct 46 ms 94400 KB Output is correct
11 Correct 49 ms 94328 KB Output is correct
12 Correct 46 ms 94300 KB Output is correct
13 Execution timed out 3092 ms 98112 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94140 KB Output is correct
2 Correct 44 ms 94164 KB Output is correct
3 Correct 58 ms 94152 KB Output is correct
4 Correct 58 ms 94152 KB Output is correct
5 Correct 56 ms 94236 KB Output is correct
6 Correct 54 ms 94176 KB Output is correct
7 Correct 55 ms 94212 KB Output is correct
8 Correct 57 ms 94260 KB Output is correct
9 Correct 44 ms 94104 KB Output is correct
10 Correct 44 ms 94144 KB Output is correct
11 Correct 47 ms 94304 KB Output is correct
12 Correct 47 ms 94152 KB Output is correct
13 Correct 53 ms 94184 KB Output is correct
14 Correct 53 ms 94260 KB Output is correct
15 Correct 46 ms 94280 KB Output is correct
16 Correct 46 ms 94284 KB Output is correct
17 Correct 46 ms 94252 KB Output is correct
18 Correct 46 ms 94400 KB Output is correct
19 Correct 49 ms 94328 KB Output is correct
20 Correct 46 ms 94300 KB Output is correct
21 Correct 46 ms 94220 KB Output is correct
22 Correct 45 ms 94264 KB Output is correct
23 Correct 45 ms 94152 KB Output is correct
24 Correct 46 ms 94264 KB Output is correct
25 Correct 50 ms 94308 KB Output is correct
26 Correct 54 ms 94248 KB Output is correct
27 Correct 52 ms 94316 KB Output is correct
28 Correct 49 ms 94296 KB Output is correct
29 Correct 57 ms 94164 KB Output is correct
30 Correct 58 ms 94152 KB Output is correct
31 Correct 46 ms 94388 KB Output is correct
32 Correct 46 ms 94312 KB Output is correct
33 Correct 49 ms 94212 KB Output is correct
34 Correct 46 ms 94192 KB Output is correct
35 Correct 48 ms 94180 KB Output is correct
36 Correct 45 ms 94408 KB Output is correct
37 Correct 58 ms 94408 KB Output is correct
38 Correct 57 ms 94424 KB Output is correct
39 Correct 45 ms 94172 KB Output is correct
40 Correct 46 ms 94228 KB Output is correct
41 Correct 50 ms 94276 KB Output is correct
42 Correct 47 ms 94152 KB Output is correct
43 Execution timed out 3060 ms 94452 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94140 KB Output is correct
2 Correct 44 ms 94164 KB Output is correct
3 Correct 58 ms 94152 KB Output is correct
4 Correct 58 ms 94152 KB Output is correct
5 Correct 56 ms 94236 KB Output is correct
6 Correct 54 ms 94176 KB Output is correct
7 Correct 55 ms 94212 KB Output is correct
8 Correct 57 ms 94260 KB Output is correct
9 Correct 44 ms 94104 KB Output is correct
10 Correct 44 ms 94144 KB Output is correct
11 Correct 47 ms 94304 KB Output is correct
12 Correct 47 ms 94152 KB Output is correct
13 Correct 53 ms 94184 KB Output is correct
14 Correct 53 ms 94260 KB Output is correct
15 Correct 46 ms 94280 KB Output is correct
16 Correct 46 ms 94284 KB Output is correct
17 Correct 46 ms 94252 KB Output is correct
18 Correct 46 ms 94400 KB Output is correct
19 Correct 49 ms 94328 KB Output is correct
20 Correct 46 ms 94300 KB Output is correct
21 Correct 46 ms 94220 KB Output is correct
22 Correct 45 ms 94264 KB Output is correct
23 Correct 45 ms 94152 KB Output is correct
24 Correct 46 ms 94264 KB Output is correct
25 Correct 50 ms 94308 KB Output is correct
26 Correct 54 ms 94248 KB Output is correct
27 Correct 52 ms 94316 KB Output is correct
28 Correct 49 ms 94296 KB Output is correct
29 Correct 57 ms 94164 KB Output is correct
30 Correct 58 ms 94152 KB Output is correct
31 Correct 46 ms 94388 KB Output is correct
32 Correct 46 ms 94312 KB Output is correct
33 Correct 49 ms 94212 KB Output is correct
34 Correct 46 ms 94192 KB Output is correct
35 Correct 48 ms 94180 KB Output is correct
36 Correct 45 ms 94408 KB Output is correct
37 Correct 58 ms 94408 KB Output is correct
38 Correct 57 ms 94424 KB Output is correct
39 Correct 45 ms 94172 KB Output is correct
40 Correct 46 ms 94228 KB Output is correct
41 Correct 50 ms 94276 KB Output is correct
42 Correct 47 ms 94152 KB Output is correct
43 Execution timed out 3092 ms 98112 KB Time limit exceeded
44 Halted 0 ms 0 KB -