제출 #564178

#제출 시각아이디문제언어결과실행 시간메모리
564178cheissmartMisspelling (JOI22_misspelling)C++14
100 / 100
1582 ms206720 KiB
#include <bits/stdc++.h> #define IO_OP ios::sync_with_stdio(0), cin.tie(0) #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7, N = 5e5 + 7, M = 1e9 + 7; void add(int& a, int b) { a += b; if(a >= M) a -= M; } V<pi> G[N]; struct DS { int sum; V<pi> pq; void upd(int pos, int val) { pq.PB({pos, val}); add(sum, val); } void remove_less_than(int pos) { while(pq.size() && pq.back().F < pos) { add(sum, M - pq.back().S); pq.pop_back(); } } } ds[26][2]; signed main() { IO_OP; int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--, b--; assert(a != b); if(a < b) { G[a].EB(b, 1); } else { G[b].EB(a, 0); } } for(int c = 0; c < 26; c++) ds[c][0].upd(n - 1, 1); for(int i = n - 2; i >= 0; i--) { V<array<int, 4>> todo; for(int c = 0; c < 26; c++) { int he = 0, be = 0; for(int cc = 0; cc < 26; cc++) { if(cc < c) add(he, ds[cc][0].sum), add(he, ds[cc][1].sum); if(cc > c) add(be, ds[cc][0].sum), add(be, ds[cc][1].sum); } todo.PB({c, 0, i, he}); todo.PB({c, 1, i, be}); } for(auto[c, tp, pos, x]:todo) ds[c][tp].upd(pos, x); for(auto[j, tp]:G[i]) for(int c = 0; c < 26; c++) ds[c][tp].remove_less_than(j); } int ans = 0; for(int c = 0; c < 26; c++) add(ans, ds[c][0].sum), add(ans, ds[c][1].sum); cout << ans << '\n'; }

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

misspelling.cpp: In function 'int main()':
misspelling.cpp:73:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   73 |   for(auto[c, tp, pos, x]:todo)
      |           ^
misspelling.cpp:75:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   75 |   for(auto[j, tp]:G[i])
      |           ^
#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...