제출 #247021

#제출 시각아이디문제언어결과실행 시간메모리
247021bibabasNekameleoni (COCI15_nekameleoni)C++14
56 / 140
3094 ms42028 KiB
#pragma GCC optimize("fast-math,Ofast,inline,no-stack-protector,profile-values,data-sections,-ffast-math,-fgcse") #pragma GCC optimize("branch-target-load-optimize,branch-target-load-optimize2,btr-bb-exclusive,-fpeephole2") #include <bits/stdc++.h> #define ll long long #define ull unsigned int #define vi vector<int> #define vvi vector<vi> #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define ld long double #define pii pair<int, int> #define mt make_tuple #define mn(a, b) a = min(a, b) #define mx(a, b) a = max(a, b) using namespace std; const int INF = (int)2e9; const int inf = (int)2e18; const ld eps = (ld)1e-8; const int mod = (int)10007; const int MAXN = (int)1e4 + 1; const int MAXC = (int)1e6 + 1; const int MAXE = (int)1000; const int MAXLOG = 21; const int maxlen = (int)1e5; const int asci = (int)256; const int block = 480; const ld PI = acos(-1); const ld e = 2.7182818284; /*#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/ template <class T> istream& operator >>(istream &in, vector<T> &arr){ for (T &cnt : arr) { in >> cnt; } return in; }; int k; int used[50], cnt[50]; struct nums{ vector<pii> p, s; int ans = INF; nums() {} nums(int pos, int x) { p.push_back(mp(x, pos)); s.push_back(mp(x, pos)); } nums(vector<pii> p, vector<pii> s, int ans): p(p), s(s), ans(ans) {} }; nums merge(nums a, nums b) { vector<pii> p = a.p; memset(used, 0, sizeof used); for (int i = 0; i < p.size(); ++i) { used[p[i].first] = 1; } for (int i = 0; i < b.p.size(); ++i) { if (!used[b.p[i].first]) p.push_back(b.p[i]); used[b.p[i].first] = 1; } vector<pii> s = b.s; memset(used, 0, sizeof used); for (int i = 0; i < s.size(); ++i) { used[s[i].first] = 1; } for (int i = 0; i < a.s.size(); ++i) { if (!used[a.s[i].first]) s.push_back(a.s[i]); used[a.s[i].first] = 1; } memset(cnt, 0, sizeof cnt); int ost = k; int ans = min(a.ans, b.ans); for (int i = 0; i < b.p.size(); ++i) cnt[b.p[i].first]++, ost--; int l = 0, r = b.p.size() - 1; for (; l < a.s.size() && r > -1; ++l) { ++cnt[a.s[l].first]; if (cnt[a.s[l].first] == 1) ost--; while (r && cnt[b.p[r].first] > 1) { cnt[b.p[r].first]--; r--; } if (!ost) ans = mn(ans, b.p[max(r, 0)].second - a.s[l].second + 1); } return nums(p, s, ans); } struct stree{ nums t[400000]; void build(int v, int tl, int tr, vi &a) { if (tl + 1 == tr) { t[v] = nums(tl, a[tl]); return; } int tm = (tl + tr) / 2; build(2 * v, tl, tm, a); build(2 * v + 1, tm, tr, a); t[v] = merge(t[2 * v], t[2 * v + 1]); } void upd(int v, int tl, int tr, int pos, int x) { if (tl + 1 == tr) { t[v] = nums(pos, x); return; } int tm = (tl + tr) / 2; if (pos < tm) upd(2 * v, tl, tm, pos, x); else upd(2 * v + 1, tm, tr, pos, x); t[v] = merge(t[2 * v], t[2 * v + 1]); } int ans() { return t[1].ans; } }; stree t; void solve() { int n, q; scanf("%d %d %d", &n, &k, &q); vi a(n); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); for (int i = 0; i < n; ++i) a[i]--; t.build(1, 0, n, a); while (q--) { int type; scanf("%d", &type); if (type == 1) { int p, v; scanf("%d %d", &p, &v); p--, v--; t.upd(1, 0, n, p, v); } else { int otv = t.ans(); if (otv == INF) cout << "-1\n"; else cout << otv << "\n"; } } } signed main() { srand(time(0)); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #endif cout.precision(30); solve(); return 0; }

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

nekameleoni.cpp:1:113: warning: bad option '-fprofile-values' to pragma 'optimize' [-Wpragmas]
 #pragma GCC optimize("fast-math,Ofast,inline,no-stack-protector,profile-values,data-sections,-ffast-math,-fgcse")
                                                                                                                 ^
nekameleoni.cpp:1:113: warning: bad option '-fdata-sections' to pragma 'optimize' [-Wpragmas]
nekameleoni.cpp:46:49: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
 istream& operator >>(istream &in, vector<T> &arr){
                                                 ^
nekameleoni.cpp:46:49: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:60:10: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     nums() {}
          ^
nekameleoni.cpp:60:10: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:61:24: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     nums(int pos, int x) {
                        ^
nekameleoni.cpp:61:24: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:65:47: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     nums(vector<pii> p, vector<pii> s, int ans): p(p), s(s), ans(ans) {}
                                               ^
nekameleoni.cpp:65:47: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:68:26: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
 nums merge(nums a, nums b) {
                          ^
nekameleoni.cpp:68:26: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp: In function 'nums merge(nums, nums)':
nekameleoni.cpp:71:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < p.size(); ++i) {
                     ~~^~~~~~~~~~
nekameleoni.cpp:74:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < b.p.size(); ++i) {
                     ~~^~~~~~~~~~~~
nekameleoni.cpp:80:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); ++i) {
                     ~~^~~~~~~~~~
nekameleoni.cpp:83:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.s.size(); ++i) {
                     ~~^~~~~~~~~~~~
nekameleoni.cpp:90:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < b.p.size(); ++i) cnt[b.p[i].first]++, ost--;
                     ~~^~~~~~~~~~~~
nekameleoni.cpp:92:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (; l < a.s.size() && r > -1; ++l) {
            ~~^~~~~~~~~~~~
nekameleoni.cpp:98:23: warning: operation on 'ans' may be undefined [-Wsequence-point]
         if (!ost) ans = mn(ans, b.p[max(r, 0)].second - a.s[l].second + 1);
                       ^
nekameleoni.cpp: At global scope:
nekameleoni.cpp:106:44: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     void build(int v, int tl, int tr, vi &a) {
                                            ^
nekameleoni.cpp:106:44: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:117:51: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     void upd(int v, int tl, int tr, int pos, int x) {
                                                   ^
nekameleoni.cpp:117:51: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:128:13: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
     int ans() {
             ^
nekameleoni.cpp:128:13: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:135:12: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
 void solve() {
            ^
nekameleoni.cpp:135:12: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp:155:13: warning: bad option '-fprofile-values' to attribute 'optimize' [-Wattributes]
 signed main() {
             ^
nekameleoni.cpp:155:13: warning: bad option '-fdata-sections' to attribute 'optimize' [-Wattributes]
nekameleoni.cpp: In function 'void solve()':
nekameleoni.cpp:136:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n, q; scanf("%d %d %d", &n, &k, &q);
               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nekameleoni.cpp:138:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
                                 ~~~~~^~~~~~~~~~~~~
nekameleoni.cpp:142:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int type; scanf("%d", &type);
                   ~~~~~^~~~~~~~~~~~~
nekameleoni.cpp:144:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int p, v; scanf("%d %d", &p, &v);
                       ~~~~~^~~~~~~~~~~~~~~~~
nekameleoni.cpp: In constructor 'nums::nums()':
nekameleoni.cpp:60:13: warning: branch target register load optimization is not intended to be run twice
     nums() {}
             ^
#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...
#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...