Submission #564206

#TimeUsernameProblemLanguageResultExecution timeMemory
564206cheissmartMisspelling (JOI22_misspelling)C++14
100 / 100
856 ms206684 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, 3>> todo; int he = 0, be = 0; for(int c = 0; c < 26; c++) add(be, ds[c][0].sum), add(be, ds[c][1].sum); for(int c = 0; c < 26; c++) { if(c) add(he, ds[c - 1][0].sum), add(he, ds[c - 1][1].sum); add(be, M - ds[c][0].sum), add(be, M - ds[c][1].sum); todo.PB({c, 0, he}); todo.PB({c, 1, be}); } for(auto[c, tp, x]:todo) ds[c][tp].upd(i, 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'; }

Compilation message (stderr)

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