#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while (c < '0' || c > '9')
{
c = getchar_unlocked();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + c - '0';
c = getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf = 1e9;
const ll mod2 = 1e9+7;
const int mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
if(x+y>=mod2) x-=mod2;
if(x+y<0)x+=mod2;
return x+y;
}
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a, b, c;
};
struct id
{
int a, b, c, d;
};
struct ie
{
int a, b, c, d, e;
};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center;
int i, s10, s12,s11,t,lim,w,l,r;
int kk;
int el = 19;
ld k1,k2,k3;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
// modwwe
phongbeo(),down
// checktime
}
bool cmp(ib a,ib b)
{
return a.a<b.a;
}
deque<ib> s;
vector<ib> v[100007];
int c[3];
ib a[100007];
struct segtree
{
int t[400007];
int t2[400007];
int t3[400007];
int lazy[400007];
int sz[400007];
void apply(int node,int x)
{
t[node]=x*sz[node];
t2[node]=x;
t3[node]=x;
lazy[node]=x;
}
int mer(int x,int y)
{
return x+y;
}
void ff(int x)
{
for(int i=x*2; i<=x*2+1; i++)
apply(i,lazy[x]);
lazy[x]=0;
}
void build(int node,int l,int r)
{
sz[node]=r-l+1;
if(l==r) return;
int mid=l+r>>1;
build(node<<1,l,mid);
build(node<<1|1,mid+1,r);
}
void upd(int node,int l,int r,int l1,int r1,int x)
{
if(l>r1||r<l1||t2[node]>=x) return;
if(l>=l1&&r<=r1&&t3[node]<=x)
{
apply(node,x);
return;
}
if(lazy[node]!=0)ff(node);
int mid=l+r>>1;
upd(node<<1,l,mid,l1,r1,x);
upd(node<<1|1,mid+1,r,l1,r1,x);
t[node]=mer(t[node<<1],t[node<<1|1]);
t2[node]=min(t2[node<<1],t2[node<<1|1]);
t3[node]=max(t3[node<<1],t3[node<<1|1]);
}
} st;
void phongbeo()
{
cin>>n;
for(int i=1; i<=n; i++)
{
char x;
cin>>l>>x;
if(x=='B')r=0;
else if(x=='G')r=1;
else r=2;
a[i]= {l,r};
}
sort(a+1,a+1+n,cmp);
for(int i=1; i<=n; i++)
{
s.push_back({a[i].a,a[i].b});
c[a[i].b]++;
while(s.back().a>=s.front().a*2)
{
c[s.front().b]--;
s.pop_front();
}
v[c[0]].pb({c[1],c[2]});
}
st.build(1,0,n);
for(int i=n; i>=0; --i)
{
for(auto x:v[i])st.upd(1,0,n,0,x.a,x.b+1);
s4+=st.t[1];
}
if(s4!=0)s4--;
cout<<s4;
}
컴파일 시 표준 에러 (stderr) 메시지
rotate.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
75 | main()
| ^~~~
rotate.cpp: In function 'int main()':
rotate.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
rotate.cpp:79:9: note: in expansion of macro 'fin'
79 | fin(task);
| ^~~
rotate.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define fou(x) freopen(x".ans","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
rotate.cpp:80:9: note: in expansion of macro 'fou'
80 | fou(task);
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |