이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
const long long du = 1e9 + 7;
const int maxn = 5e5 + 9;
long long f[maxn][26];
pii a[maxn];
long long pf[maxn][26];
vector<int>add1[maxn], del1[maxn], add2[maxn], del2[maxn];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("temp.INP","r",stdin);
//freopen("temp.OUT","w",stdout);
int n, m;
cin >> n >> m;
for1(i, 1, m)cin >> a[i].fi >> a[i].se;
for1(j, 0, 25)f[1][j] = pf[1][j] = 1;
multiset<int>sml, grt;
sml.insert(0);
grt.insert(0);
for1(i, 1, m) {
if (a[i].fi < a[i].se) {
add1[a[i].fi].pb(a[i].fi);
del1[a[i].se].pb(a[i].fi);
} else {
add2[a[i].se].pb(a[i].se);
del2[a[i].fi].pb(a[i].se);
}
}
for1(i, 1, 1) {
for (auto v : add1[i])
sml.insert(v);
for (auto v : add2[i])
grt.insert(v);
for (auto v : del1[i])
sml.erase(sml.find(v));
for (auto v : del2[i])
grt.erase(grt.find(v));
}
for1(i, 2, n) {
for1(j, 0, 25) {
for1(k, 0, 25) {
if (j == k)
continue;
if (j < k) {
auto it = sml.end();
it--;
f[i][k] = (f[i][k] + pf[i - 1][j] - pf[(*it)][j] + 2 * du) % du;
} else {
auto it = grt.end();
it--;
f[i][k] = (f[i][k] + pf[i - 1][j] - pf[(*it)][j] + 2 * du) % du;
}
}
}
for (auto v : del1[i])
sml.erase(sml.find(v));
for (auto v : del2[i])
grt.erase(grt.find(v));
for (auto v : add1[i])
sml.insert(v);
for (auto v : add2[i])
grt.insert(v);
for1(j, 0, 26)pf[i][j] = (pf[i - 1][j] + f[i][j]) % du;
}
long long ans = 0;
for1(i, 1, n)for1(j, 0, 25)ans = (ans + f[i][j]) % du;
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
misspelling.cpp: In function 'int main()':
misspelling.cpp:88:46: warning: iteration 26 invokes undefined behavior [-Waggressive-loop-optimizations]
88 | for1(j, 0, 26)pf[i][j] = (pf[i - 1][j] + f[i][j]) % du;
| ~~~~~~~~~~~^
misspelling.cpp:7:34: note: within this loop
7 | #define for1(i,j,k) for(int i=j;i<=k;i++)
......
88 | for1(j, 0, 26)pf[i][j] = (pf[i - 1][j] + f[i][j]) % du;
| ~~~~~~~~
misspelling.cpp:88:9: note: in expansion of macro 'for1'
88 | for1(j, 0, 26)pf[i][j] = (pf[i - 1][j] + f[i][j]) % du;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |