Submission #1090278

#TimeUsernameProblemLanguageResultExecution timeMemory
1090278Neco_arcMisspelling (JOI22_misspelling)C++17
100 / 100
663 ms165516 KiB
#include <bits/stdc++.h> #ifdef LOCAL #include <bits/debug.hpp> #endif // LOCAL #define ll long long #define all(x) x.begin(), x.end() #define Neco "Misspelling" #define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin()) #define getbit(x,i) ((x >> i)&1) #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define cntbit(x) __builtin_popcountll(x) #define fi(i, a, b) for(int i = a; i <= b; i++) #define fid(i, a, b) for(int i = a; i >= b; i--) #define maxn (int) 5e5 + 1 using namespace std; const ll mod = 1e9 + 7; //972663749 const ll base = 911382323; int n, q; int dp[26], pre[2][maxn]; int Sum[26][2], del[maxn][26][2]; vector<pair<int, int>> P[2][maxn]; void Add(int &x, int y) { ll p = 1ll * x + y; if(p >= mod) p -= mod; x = p; } void prepare(int type) { multiset<int> S = {0}; fi(i, 1, n) { for(auto [x, t] : P[type][i]) { if(t == 1) S.insert(x); else S.erase(S.find(x)); } pre[type][i] = *S.rbegin(); } } void solve() { cin >> n >> q; fi(i, 1, q) { int x, y; cin >> x >> y; if(x == y) continue; int w = 1; if(x > y) swap(x, y), w = 0; P[w][x + 1].push_back({x, 1}), P[w][y + 1].push_back({x, -1}); } prepare(0), prepare(1); fid(i, n, 1) { fi(c, 0, 25) fi(t, 0, 1) Add(Sum[c][t], mod - del[i][c][t]); fi(c, 0, 25) dp[c] = 1; int S = 0; fi(c, 0, 25) { Add(dp[c], S); Add(S, Sum[c][0]); } S = 0; fid(c, 25, 0) { Add(dp[c], S); Add(S, Sum[c][1]); } fi(c, 0, 25) { fi(t, 0, 1) { Add(Sum[c][t], dp[c]); Add(del[pre[t][i]][c][t], dp[c]); } } } int ans = 0; fi(i, 0, 25) Add(ans, dp[i]); cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(Neco".inp", "r")) { freopen(Neco".inp", "r", stdin); freopen(Neco".out", "w", stdout); } int nTest = 1; // cin >> nTest; while(nTest--) { solve(); } return 0; }

Compilation message (stderr)

misspelling.cpp: In function 'int main()':
misspelling.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |         freopen(Neco".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
misspelling.cpp:100:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |         freopen(Neco".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...