제출 #547793

#제출 시각아이디문제언어결과실행 시간메모리
547793nonsensenonsense1Misspelling (JOI22_misspelling)C++17
100 / 100
680 ms57808 KiB
#include <cstdio> #include <utility> #include <algorithm> const int md = 1000000007; inline int add(int a, int b) { a += b; if (a >= md) a -= md; return a; } inline int sub(int a, int b) { a -= b; if (a < 0) a += md; return a; } inline int mul(int a, int b) { return (long long)a * b % md; } const int A = 26; const int N = 500000; int n, m, d[N][A], sum[2][A]; bool u[2][N]; std::pair<std::pair<int, int>, bool> a[N]; std::vector<int> un[2]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; ++i) { int x, y; scanf("%d%d", &x, &y); --x; --y; if (x < y) a[i] = std::make_pair(std::make_pair(x, y), 1); else a[i] = std::make_pair(std::make_pair(y, x), 0); } std::sort(a, a + m); for (int i = n - 1, j = m - 1; i >= 0; --i) { if (i + 1 < n) { for (int j = 0; j < A; ++j) for (int k = 0; k < 2; ++k) sum[k][j] = add(sum[k][j], d[i + 1][j]); un[0].push_back(i); un[1].push_back(i); } while (j >= 0 && a[j].first.first == i) { while (!un[a[j].second].empty() && un[a[j].second].back() < a[j].first.second) { for (int k = 0; k < A; ++k) sum[!a[j].second][k] = sub(sum[!a[j].second][k], d[un[a[j].second].back() + 1][k]); un[a[j].second].pop_back(); } --j; } for (int x = 0; x < A; ++x) { d[i][x] = 1; for (int y = x + 1; y < A; ++y) d[i][x] = add(d[i][x], sum[0][y]); for (int y = 0; y < x; ++y) d[i][x] = add(d[i][x], sum[1][y]); } } int ans = 0; for (int i = 0; i < A; ++i) ans = add(ans, d[0][i]); printf("%d\n", ans); return 0; }

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

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