제출 #1282649

#제출 시각아이디문제언어결과실행 시간메모리
1282649khanhgngMonochrome Points (JOI20_monochrome)C++20
0 / 100
1 ms576 KiB
//#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #define ll long long #define int long long #define ld long double #define pb push_back #define pii pair<int, int> #define fi first #define se second #define bit(i, x) ((x >> i) & 1) #define SZ(x) ((int)(x.size())) #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define task "test" using namespace std; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll Rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); } const int MAXn = 5e5+10; const int MAX = 1e5+10; const ll INF = (long long)(1e18); const ll INF1 = (long long)(1e17); const int MOD = 1e9 + 7; const int MOD1 = 111539786; const int BASE = 3137; const int BL = 340; int n,b[MAXn]; char a[MAXn]; vector<int>vec[2]; struct BIT{ int N,f[MAXn*4]; void init(int n){ N=n; FOR(i,1,n)f[i]=0; } void upd(int idx){ for(int i=idx;i<=N;i+=(i&-i))++f[i]; } int get(int idx){ int res=0; for(int i=idx;i>0;i-=(i&-i))res+=f[i]; return res; } }st; void solution() { cin>>n; FOR(i,1,n)cin>>a[i]; FOR(i,n+1,2*n){ cin>>a[i]; if(a[i]=='W'){ vec[0].pb(i); } else { vec[1].pb(i); } } int u=0,v=0; FOR(i,1,n){ if(a[i]=='W'){ b[i]=vec[1][v]; ++v; } else { b[i]=vec[0][u]; ++u; } } st.init(2*n+5); int res=0; FORD(i,n,1){ res+=st.get(2*n+1)-st.get(b[i]); st.upd(b[i]); } cout<<res; } int32_t main() { if (fopen(task".inp", "r")){freopen(task".inp", "r", stdin);freopen(task".out", "w", stdout);} ios::sync_with_stdio(0); cin.tie(0); int ntest = 1;///cin >> ntest; while (ntest--) solution(); cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "s "; }

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

monochrome.cpp: In function 'int32_t main()':
monochrome.cpp:85:40: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |     if (fopen(task".inp", "r")){freopen(task".inp", "r", stdin);freopen(task".out", "w", stdout);}
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
monochrome.cpp:85:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |     if (fopen(task".inp", "r")){freopen(task".inp", "r", stdin);freopen(task".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...