제출 #569062

#제출 시각아이디문제언어결과실행 시간메모리
569062dantoh000Misspelling (JOI22_misspelling)C++14
100 / 100
1200 ms116480 KiB
#include <bits/stdc++.h> using namespace std; int n,m; int up[500005]; int down[500005]; int dp[500005][30]; set<int> gup, gdown; int tot[500005]; int mod = 1000000007; int main(){ scanf("%d%d",&n,&m); for (int i = 1; i <= n; i++){ up[i] = down[i] = i; } for (int i = 0,a,b; i < m; i++){ scanf("%d%d",&a,&b); if (a < b) up[a] = max(up[a], b); else down[b] = max(down[b], a); } for (int i = 1; i <= n+1; i++){ gup.insert(i); gdown.insert(i); } for (int i = 0; i < 26; i++) tot[i] = 1; for (int i = n; i >= 1; i--){ while (*gup.lower_bound(i+1) <= up[i]){ int tmp = *gup.lower_bound(i+1); gup.erase(tmp); ///printf("%d cannot transition to %d up\n"); int pfx = 0; for (int j = 25; j >= 0; j--){ tot[j] = (tot[j] - pfx + mod)%mod; pfx = (pfx + dp[tmp][j])%mod; } } while (*gdown.lower_bound(i+1) <= down[i]){ int tmp = *gdown.lower_bound(i+1); gdown.erase(tmp); ///printf("%d cannot transition to %d down\n"); int pfx = 0; for (int j = 0; j < 26; j++){ tot[j] = (tot[j] - pfx + mod)%mod; pfx = (pfx + dp[tmp][j])%mod; } } int sum = 0; for (int j = 0; j < 26; j++){ dp[i][j] = tot[j]; //printf("%d ",dp[i][j]); sum = (sum+dp[i][j])%mod; } //printf("\n"); for (int j = 0; j < 26; j++){ tot[j] = ((tot[j] + sum)%mod - dp[i][j] + mod)%mod; } } int ans = 0; for (int i = 0; i < 26; i++){ ans = (ans + dp[1][i])%mod; } printf("%d\n",ans); }

컴파일 시 표준 에러 (stderr) 메시지

misspelling.cpp: In function 'int main()':
misspelling.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
misspelling.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
#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...