이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define pii pair<int, int>
#define fi first
#define se second
#define mod 1000000007
#define A 26
typedef long long ll;
using namespace std;
struct modular{
int a;
modular(int x = 0){a = x;}
modular operator+(modular t){return {(a+t.a)%mod};}
modular operator-(modular t){return {(a-t.a+mod)%mod};}
void operator+=(modular t){a = (a+t.a)%mod;}
};
int main(){
int n, m;
scanf("%d%d", &n, &m);
vector<pii> wym;
while(m--){
int a, b;
scanf("%d%d", &a, &b);
wym.emplace_back(a, b);
}
vector<vector<modular>> dp(n+1, vector<modular>(A, 0));
REP(lit, A) dp[1][lit] = 1;
FOR(pref, 1, n-1) REP(lit, A){
modular t = dp[pref][lit];
int dol = 0;
for(pii i : wym){
if(i.fi < i.se) continue;
int p = min(i.fi, i.se);
int k = max(i.fi, i.se);
if(p <= pref && pref < k) dol = max(dol, p);
}
int gora = 0;
for(pii i : wym){
if(i.fi > i.se) continue;
int p = min(i.fi, i.se);
int k = max(i.fi, i.se);
if(p <= pref && pref < k) gora = max(gora, p);
}
REP(nowa, A){
int ogr = 0;
if(nowa < lit) ogr = dol;
if(nowa > lit) ogr = gora;
dp[pref+1][nowa] += t-dp[ogr][lit];
}
}
modular wyn = 0;
REP(lit, A) wyn += dp[n][lit];
printf("%d", wyn.a);
}
컴파일 시 표준 에러 (stderr) 메시지
misspelling.cpp: In function 'int main()':
misspelling.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
misspelling.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d%d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~
# | 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... |