總結——關於2017 10 9測試的分析總結

NOIP 2017 模拟


2017 10 9



T1 :


题目:

AHOI 2003








显而易见这是一道简单的字符串处理题。

毫无悬念的Ac。


代码:

#include<string>
#include<cstdio>
#include<map>
#define pow4(x) x*x*x*x
using namespace std;
int n,t;
map <string,int> m;
inline bool get()
{
	char c=getchar();
	while((c<'a'||c>'z')&&(c<'A'||c>'Z')) if((c=getchar())==EOF) return false;
	string s="";
	while((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
	{
		if(c>='A'&&c<='Z') c=c-'A'+'a';
		s+=c;
		c=getchar();
	}
	++m[s];
	++n;
	return true;
}
int main()
{
	while(get());
	for(map <string,int> :: iterator it=m.begin();it!=m.end();++it) t+=pow4(it->second);
	printf("%d %d\n",t,n);
	return 0;
}





T2 : 


题目:





好吧,我承认我脑洞太大,太神化出题人了。。。。。。



正解:


var
n, i, j, l, r, x, si, fj, ti, tj ,ans : longint;
t, s, f : array [0..1001] of longint;
function max (a, b : longint) : longint;
begin
        if a > b then exit (a)
        else exit (b);
end;
function min (a, b : longint) : longint;
begin
        if a > b then exit (b)
        else exit (a);
end;
begin
        read (n);
        for i := 1 to n do read (t[i], s[i], f[i]);
        for i := 1 to n do begin
                ans := 0;
                for j := 1 to n do
                        if i <> j then begin
                                if (s[i] < f[i]) and (s[j] < f[j]) then begin
                                        l := max (s[i], s[j]);
                                        r := min (f[i], f[j]);
                                        if l > r then continue;
                                        if t[i] - s[i] = t[j] - s[j] then inc (ans);
                                end
                                else if (s[i] > f[i]) and (s[j] > f[j]) then begin
                                        l := min (s[i], s[j]);
                                        r := max (f[i], f[j]);
                                        if l < r then continue;
                                        if s[i] + t[i] = s[j] + t[j] then inc (ans);
                                end
                                else begin
                                        if s[i] < f[i] then begin
                                                si := s[i];
                                                ti := t[i];
                                                fj := s[j];
                                                tj := t[j];
                                                l := max (s[i], f[j]);
                                                r := min (f[i], s[j]);
                                        end
                                        else begin
                                                si := s[j];
                                                ti := t[j];
                                                fj := s[i];
                                                tj := t[i];
                                                l := max (s[j], f[i]);
                                                r := min (f[j], s[i]);
                                        end;
                                        if l > r then continue;
                                        x := tj - ti + si + fj;
                                        if (x >= l * 2) and (x <= r * 2) then inc(ans);
                                end;
                        end;
                write (ans, ' ');
        end;
end.






T3 : 


题目:





题解找不到了,那就水一发吧。。。


#include<cstdio>
#include<algorithm>
#define lowbit(i) i&-i
#define add(a) for(;a.orz<=200001;a.orz+=lowbit(a.orz)) sum[a.orz]+=a.num,++day[a.orz]
#define want(a) int x=0; for(;i;i-=lowbit(i)) x+=a[i]; return x
struct node{
	int num,orz;
	inline bool operator < (const node &a) const{return num>a.num;};
}t[200010],d[200010];
int n,m;
int r[200010],day[200010],ans[200010],sum[200010];
inline int read()
{
	int i=0;
	char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') i=(i<<3)+(i<<1)+c-48,c=getchar();
	return i;
}
inline void write(int x)
{
	short sum=0;
	char c[10];
	do c[++sum]=x%10+48,x/=10; while(x);
	while(sum) putchar(c[sum--]);
	putchar(' ');
}
inline int qsum(int i) {want(sum);}
inline int qday(int i) {want(day);}
int main() {
	n=read();
	m=read();
	for(int i=1;i<=m;++i) t[i].num=read(),t[i].orz=i;
	for(int i=1;i<=n;++i) d[i].num=read(),r[i]=read(),d[i].orz=i;
	std::sort(t+1,t+m+1);
	std::sort(d+1,d+n+1);
	for(int i=1,head=1;i<=n;++i) {
		while(t[head].num>d[i].num&&head<=m) {
			add(t[head]);
			++head;
		}
		int _l=0,_r=m+1;
		while(_l+1<_r) {
			int mid=_l+_r>>1;
			qsum(mid)-qday(mid)*d[i].num>=r[d[i].orz] ? _r=mid : _l=mid;
		}
		ans[d[i].orz]=_l==m ? 0 : _r;
	}
	for(int i=1;i<=n;++i) write(ans[i]);
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值