上午
改题
让我知道了有!!F这个东西
第一题终于对了
下午
T1
模拟,取余用法
T2
暴力
正解:从后往前存储,使用两个数组line和row,记录状态并记录被涂过的位置。
#include <bits/stdc++.h>
using namespace std;
long long n,m,q,line[1000001],row[1000001],sumline=0,sumrow=0,ans=0;
struct node
{
long long x,y,z;
} a[1000001];
int main()
{
freopen("board.in","r",stdin);
freopen("board.out","w",stdout);
cin >> n >> m >> q;
for(int i=q;i>=1;i--) cin >> a[i].x >> a[i].y >> a[i].z;
for(int i=1;i<=q;i++)
{
if(a[i].x == 0)
{
if(line[a[i].y]) continue;
if(a[i].z == 1) ans += m-sumrow;
sumline++;
line[a[i].y]=1;
}
if(a[i].x == 1)
{
if(row[a[i].y]) continue;
if(a[i].z == 1) ans += n-sumline;
sumrow++;
row[a[i].y]=1;
}
}
cout << ans;
return 0;
}
T3
找错公式了……
递推
每次找到一个’a’就记录这个’a’所需要到达最后经过的b的个数,
因为特性‘ab’->’bba’所以b的个数每次增加了一个,那么下一个大冤种‘a’所需走的路程就是这次所经过b的两倍
如果是’b’那就下一个’a’所需要经过’b’的数量+1
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long f[100001],b=0,ans=0;
string s;
int main()
{
freopen("string.in","r",stdin);
freopen("string.out","w",stdout);
cin >> s;
for(int i=s.size()-1;i>=0;i--)
{
if(s[i] == 'a')
{
ans = (ans+b)%mod;
b = (b*2)%mod;
}
else b=(b+1)%mod;
}
cout << ans;
return 0;
}