publicstaticvoidsolve() { intn= io.nextInt(); char[] s = io.next().toCharArray();
longans=0L; intl= n - 1, r = n - 1; for (; l >= 0; l--) { if (s[l] == '0') { ans += r - l; r--; io.print(ans + " "); } } io.println("-1 ".repeat(r + 1)); }
publicstaticvoidsolve() { intn= io.nextInt(), m = io.nextInt(); char[] s = io.next().toCharArray();
longans=1L; for (inti=1; i < n - 1; i++) { if (s[i] == '?') ans = ans * i % MOD; }
query(s, ans); while (m-- != 0) { inti= io.nextInt() - 1; charc= io.next().charAt(0); if (i != 0 && s[i] == '?') { ans = ans * pow(i, MOD - 2) % MOD; } s[i] = c; if (i != 0 && s[i] == '?') { ans = ans * i % MOD; } query(s, ans); } }
privatestaticvoidquery(char[] s, long ans) { if (s[0] == '?') io.println(0); else io.println(ans); }
privatestaticintpow(int a, int n) { longres=1L, x = a; while (n != 0) { if ((n & 1) == 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return (int) res; }