QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687417#6470. Looping PlaylistPetroTarnavskyi#WA 1ms3840kbC++231.2kb2024-10-29 18:54:242024-10-29 18:54:26

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 18:54:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2024-10-29 18:54:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;


VI shifts = {0, 2, 4, 5, 7, 9, 11, 12};
vector<string> notes = {"Do", "Do#", "Re", "Re#", "Mi", "Fa", "Fa#", "Sol", "Sol#", "La", "La#", "Si"};


int basicNote[12];



int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	
	FOR(i, 0, 12)
	{
		if(notes[i].back() == '#')
			continue;
		for(int sh : shifts)
			basicNote[(i + sh) % 12] |= 1 << i;
	}
	
	int n;
	cin >> n;
	int mask = 0;
	int ans = 0;
	
	FOR(i, 0, n)
	{
		string s;
		cin >> s;
		int id = -1;
		FOR(j, 0, 12)
			if(notes[j] == s)
				id = j;
		assert(id != -1);
		
		mask = mask & basicNote[id];
		if(mask == 0)
		{
			ans++;
			mask = basicNote[id];
		}		
	}
	cout << ans << "\n";
	
	
	
	
	




	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3840kb

input:

8
La
Si
Do
Si
La
Sol
Fa
Mi


output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

9
Mi
Si
Sol
Do
Re
Fa#
Fa
Do
La


output:

2

result:

ok single line: '2'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3608kb

input:

16
Fa
Mi
Sol
Re
La
Do
Si
Fa#
Fa
Mi
Sol
Re
La
Do
Si
La#

output:

4

result:

wrong answer 1st lines differ - expected: '3', found: '4'