제출 #548208

#제출 시각아이디문제언어결과실행 시간메모리
548208fcmalkcinMisspelling (JOI22_misspelling)C++17
100 / 100
1171 ms428952 KiB
#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) 메시지

misspelling.cpp: In function 'int main()':
misspelling.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen("test.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
misspelling.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen("test.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...