제출 #446334

#제출 시각아이디문제언어결과실행 시간메모리
446334LptN21Zoltan (COCI16_zoltan)C++14
140 / 140
444 ms17104 KiB
#include <bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); #define FF first #define SS second #define pb push_back #define sz(x) (int)x.size() //#define oo 2e18 #define eps 1e-9 #define PI acos(-1.0) #define lb lower_bound #define ub upper_bound #define all(a) (a).begin(), (a).end() typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef pair<int, ii> i3; const int N = 4e5+7, M=1e6; const int MOD = 1e9+7; const int oo=1e9+1; int n, m, k, t; struct Node{ ii v; Node() {v=ii(0, 0);} Node(int f, int s) {v=ii(f, s);} } st[N<<2]; ii add(ii a, ii b) { if(a.FF>b.FF) return a; else if(a.FF<b.FF) return b; return ii(a.FF, (a.SS+b.SS)%MOD); } void update(int idx, int l0, int r0, int p, ii v, int t) { if(l0>p||r0<p) return; if(l0==r0&&l0==p) { if (t&1) st[idx].v=add(st[idx].v, v); else st[idx].v=v; return; } int mid=(l0+r0)/2; update(idx*2, l0, mid, p, v, t), update(idx*2+1, mid+1, r0, p, v, t); st[idx].v=add(st[idx*2].v, st[idx*2+1].v); } ii get(int idx, int l0, int r0, int l, int r) { if(l0>r||r0<l) return ii(0, 0); if(l<=l0&&r0<=r) return st[idx].v; int mid=(l0+r0)/2; return add(get(idx*2, l0, mid, l, r), get(idx*2+1, mid+1, r0, l, r)); } void upd(int p, ii v, int t) {update(1, 1, n, p, v, t);} ii qry(int r) {if(!r) return ii(0, 1);return max(ii(0, 1), get(1, 1, n, 1, r));} vector<int> b; int a[N]; int mul(int a, int b) {return (1LL*a*b)%MOD;} int pw(int a, int b) { if(!b) return 1; int res=pw(a, b/2); res=mul(res, res); if(b&1) res=mul(res, a); return res; } signed main() { //freopen("sapso.inp", "r", stdin); //freopen("sapso.out", "w", stdout); //fastIO; scanf("%d", &n); ii tmp; for(int i=n+1;i<=2*n;a[2*n-i+1]=a[i], b.pb(a[i++])) scanf("%d", &a[i]); sort(all(b)), b.resize(unique(all(b))-b.begin()); for(int i=1;i<=2*n;i++) { a[i]=lb(all(b), a[i])-b.begin()+1; tmp=qry(a[i]-1); upd(a[i], ii(tmp.FF+1, tmp.SS), 1); } tmp=qry(sz(b)); if(tmp.FF==n) printf("%d 1", n); else printf("%d %d", tmp.FF, mul(tmp.SS, pw(2, n-tmp.FF-1))); return 0; } /* stuff you should look for - int overflow, array bounds - special cases (n=1?) - do smth instead of do nothing and stay organized - WRITE STUFF DOWN - DONT JUST STICK ON ONE APPROACH */

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

zoltan.cpp: In function 'void update(int, int, int, int, ii, int)':
zoltan.cpp:39:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   39 |         else st[idx].v=v; return;
      |         ^~~~
zoltan.cpp:39:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   39 |         else st[idx].v=v; return;
      |                           ^~~~~~
zoltan.cpp: In function 'int pw(int, int)':
zoltan.cpp:61:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   61 |     if(b&1) res=mul(res, a); return res;
      |     ^~
zoltan.cpp:61:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   61 |     if(b&1) res=mul(res, a); return res;
      |                              ^~~~~~
zoltan.cpp: In function 'int main()':
zoltan.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     scanf("%d", &n); ii tmp;
      |     ~~~~~^~~~~~~~~~
zoltan.cpp:69:62: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     for(int i=n+1;i<=2*n;a[2*n-i+1]=a[i], b.pb(a[i++])) scanf("%d", &a[i]);
      |                                                         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...