求助,WA
查看原帖
求助,WA
238203
跟你沟通楼主2020/10/2 00:41
#include<bits/stdc++.h>
using namespace std;
int n, m, now, j, a[103];
bool book[103];
unsigned long long ans;
vector<int> v;
int move(int j)
{
	if(j+1==v.size())
		return 0;
	else return j+1;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for(j=0;j<m;++j)
		{
			cin>>book[j]>>a[j];
			if(book[j])
				v.push_back(j);
		}
		ans+=a[now];
		int cnt=a[now];
		if(book[now]) --cnt;
		for(j=now;;j=move(j))
		{
			--cnt;
			if(cnt==0) break;
		}
		if(j==0) now=v[v.size()-1];
		else now=v[j-1];
	}
	cout << ans%20123;
	return 0;
}
2020/10/2 00:41
加载中...