# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
786987 | 2023-07-18T16:12:04 Z | thimote75 | 디지털 회로 (IOI22_circuit) | C++17 | 3000 ms | 1872 KB |
#include "circuit.h" #include <bits/stdc++.h> #define num long long using namespace std; const int MOD = 1000002022; using idata = vector<signed>; using ndata = vector<num>; ndata C; ndata Gamma; idata status; idata target; int N, M; void init(int _N, int _M, idata P, idata A) { N = _N; M = _M; C .resize(N); Gamma.resize(N + 1, 1); status = A; target.resize(M); for (int i = 0; i < M; i ++) target[i] = P[i + N]; for (int i = 1; i < N + M; i ++) C[P[i]] ++; for (int i = N - 1; i >= 0; i --) Gamma[i] = (C[i] * Gamma[i + 1]) % MOD; } int count_ways(int L, int R) { L -= N; R -= N; for (int i = L; i <= R; i ++) status [i] = 1 - status[i]; idata localC(N); idata localD(N); int size_last = 0; num res = 0; for (int i = 0; i < M; i ++) { if (status[i] == 0) continue ; localC[target[i]] ++; } num avec = localC[N - 1]; num sans = C[N - 1] - localC[N - 1]; if (sans == 0 && N != 1) localC[N - 2] ++; for (int i = N - 2; i >= 0; i --) { if (localC[i] == C[i]) { avec = Gamma[i]; sans = 0; if (i != 0) localC[i - 1] ++; continue ; } avec = localC[i] * sans * Gamma[i + 1] + avec; avec %= MOD; sans = (C[i] - localC[i]) * Gamma[i + 1]; sans %= MOD; } return avec; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '431031372' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 0 ms | 208 KB | Output is correct |
10 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '431031372' |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3039 ms | 1872 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3039 ms | 1872 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '431031372' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 0 ms | 208 KB | Output is correct |
10 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '431031372' |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 208 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
8 | Correct | 1 ms | 208 KB | Output is correct |
9 | Correct | 0 ms | 208 KB | Output is correct |
10 | Incorrect | 0 ms | 208 KB | 1st lines differ - on the 1st token, expected: '52130940', found: '431031372' |
11 | Halted | 0 ms | 0 KB | - |