# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
548208 | fcmalkcin | Misspelling (JOI22_misspelling) | C++17 | 1171 ms | 428952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define F(i,a,b) for(ll i=a;i<=b;i++)
const ll maxn=5e5+100;
const ll base=3e18;
const ll mod= 1e9+7 ;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
/// have medal in APIO
/// goal 2/8
ll a[maxn];
ll b[maxn];
ll dp[maxn][28];
ll cnt[28];
ll val[maxn][28];
ll val1[maxn][28];
vector<ll> adjp[maxn];
vector<ll> adjp1[maxn];
vector<ll> adj[maxn];
vector<ll> adj1[maxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("t.inp","r"))
{
freopen("test.inp","r",stdin);
freopen("test.out","w",stdout);
}
ll n, m;
cin>> n>> m;
for (int i=1; i<=m; i++)
{
cin>> a[i]>> b[i];
if (a[i]<b[i])
{
adj[b[i]].pb(a[i]+1);
}
else
{
adj1[a[i]].pb(b[i]+1);
}
}
multiset<ll,greater<ll>> st;
multiset<ll,greater<ll>> st1;
for (int i=n; i>=1; i--)
{
for (auto to:adj[i])
{
st.insert(to);
}
for (auto to:adj1[i])
{
st1.insert(to);
}
while (st.size()&&(*st.begin())>i)
{
st.erase(st.begin());
}
while (st1.size()&&(*st1.begin())>i)
{
st1.erase(st1.begin());
}
ll pre=1;
if (st.size())
pre=(*st.begin());
ll pre1=1;
if (st1.size())
pre1=(*st1.begin());
adjp[pre1].pb(i);
adjp1[pre].pb(i);
// cout <<i<<" "<<pre<<" "<<pre1<<endl;
}
ll ans=0;
for (int i=1; i<=26; i++)
{
dp[1][i]=1;
}
for (int i=1; i<=n; i++)
{
for (auto to:adjp[i])
{
for (int t=1; t<=26; t++)
{
val[to][t]=cnt[t];
}
}
for (auto to:adjp1[i])
{
for (int t=1; t<=26; t++)
{
val1[to][t]=cnt[t];
}
}
ll cntnw=0;
for (int t=26;t>=1;t--)
{
dp[i][t]=(dp[i][t]+cntnw)%mod;
cntnw=(cntnw+cnt[t]-val[i][t]+mod)%mod;
if (i==2)
{
// cout <<dp[i][t]<<" "<<t<<" "<<cntnw<<" "<<cnt[t]<<" "<<val[i][t]<<" chk1"<<endl;
}
}
cntnw=0;
for (int t=1;t<=26;t++)
{
dp[i][t]=(dp[i][t]+cntnw)%mod;
cntnw=(cntnw+cnt[t]-val1[i][t]+mod)%mod;
if (i==2)
{
// cout <<dp[i][t]<<" "<<t<<" "<<cntnw<<" "<<cnt[t]<<" "<<val1[i][t]<<" chk2"<<endl;
}
}
for (int t=1;t<=26;t++)
{
cnt[t]=(cnt[t]+dp[i][t])%mod;
// if (i==2) cout <<dp[i][t]<<" chk1"<<endl;
}
}
for (int i=1; i<=n; i++)
for (int t=1; t<=26; t++)
ans=(ans+dp[i][t])%mod;
cout <<ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |