제출 #888291

#제출 시각아이디문제언어결과실행 시간메모리
888291raul2008487Table Tennis (info1cup20_tabletennis)C++17
72 / 100
3045 ms10032 KiB
/// R #include <bits/stdc++.h> #define ll long long #define pb push_back #define fi first #define se second #define all(v) v.begin(), v.end() #define in insert #define mpr make_pair #define vl vector<ll> #define endl '\n' using namespace std; const int sz = 2e5+5; const ll inf = 1000000000000000; //tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> rbt;a /*struct DSU{ vector<ll> e; void init(ll n){ e.assign(n+1, -1); } ll base(ll x){ if(e[x] < 0){ return x; } return e[x] = base(e[x]); } bool unite(ll a, ll b){ a = base(a); b = base(b); if(a == b){return false;} if(e[a] > e[b]){ swap(a, b); } e[a] += e[b]; e[b] = a; return true; } };*/ ll n, k, m; vl d, v(sz), bad, res; void print(vl v){ for(auto x: v){ cout << x << ' '; } cout << endl; } void solve(){ ll i, j, bg, ed, pt, w1, w2, cnt, l, r; cin>>n>>k; m = n + k; for(i=0;i<m;i++){ cin>>v[i]; } for(i=1;i<m;i++){ d.pb(v[i] - v[i-1]); } for(i=0;i<=k;i++){ for(j=0;j<=k-i;j++){ bg = i; ed = m - 2 - j; bool as = 0, tmr = 0; w1 = 0, w2 = 0; if(bg > ed){ continue; } w1 = d[bg]; w2 = d[ed]; cnt = 1; while(bg < ed){ if(w1 == w2){ cnt++; bg++;ed--; w1 = d[bg]; w2 = d[ed]; tmr = 1; continue; } else if(w1 > w2){ bad.pb(ed); ed--; w2 += d[ed]; } else{ bg++; bad.pb(bg); w1 += d[bg]; } tmr = 0; } if(tmr && cnt == (n>>1)){ l = i; r = m - j - 1; ll p = 0; for(pt = l; pt <= r; pt++){ if(p < bad.size() && pt == bad[p]){p++;continue;} res.pb(v[pt]); } print(res); return ; } bad.clear(); } } assert(0); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t=1; //cin>>t; while(t--){ solve(); } } /* 6 3 1 2 3 6 7 9 10 12 14 1 3 6 7 10 12 */

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

tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:95:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |                     if(p < bad.size() && pt == bad[p]){p++;continue;}
      |                        ~~^~~~~~~~~~~~
tabletennis.cpp:61:18: warning: unused variable 'as' [-Wunused-variable]
   61 |             bool as = 0, tmr = 0;
      |                  ^~
#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...