QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687569 | #6470. Looping Playlist | PetroTarnavskyi# | AC ✓ | 586ms | 40712kb | C++23 | 1.5kb | 2024-10-29 19:46:02 | 2024-10-29 19:46:03 |
Judging History
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)
{
for(int sh : shifts)
basicNote[(i + sh) % 12] |= 1 << i;
}
int n;
cin >> n;
VI input(n);
FOR(i, 0, n)
{
string s;
cin >> s;
int id = -1;
FOR(j, 0, 12)
if(notes[j] == s)
id = j;
assert(id != -1);
input[i] = id;
}
int ans = n;
FOR(note, 0, 12)
{
int l = 0;
while(l < n && basicNote[input[l]] & (1 << note))
l++;
if(l == n)
{
ans = 1;
break;
}
int r = n - 1;
while(r >= 0 && basicNote[input[r]] & (1 << note))
r--;
int mask = 0;
int cur = 0;
FOR(i, l, r + 1)
{
int id = input[i];
mask = mask & basicNote[id];
if(mask == 0)
{
cur++;
mask = basicNote[id];
}
}
ans = min(ans, cur + 1);
}
cout << ans << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 3500kb
input:
9 Mi Si Sol Do Re Fa# Fa Do La
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
16 Fa Mi Sol Re La Do Si Fa# Fa Mi Sol Re La Do Si La#
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
16 La# Si Do La Re Sol Mi Fa Fa# Si Do La Re Sol Mi Fa
output:
3
result:
ok single line: '3'
Test #5:
score: 0
Accepted
time: 586ms
memory: 38524kb
input:
9000026 Sol Do La# La# Do# La# Sol# Sol# Re# Do# Do Sol Do# Sol# Do# La# Do Do La# Sol Sol# Fa Sol# Fa# Re Mi Mi Re Mi La Sol# Fa# Fa# Sol# Sol# Mi Sol# Re La Sol# Mi Fa# La Si Sol# La Re Fa# La Sol# Fa# Do# Mi Si Do Si Re Re Sol Do Re Do La La Si Mi Sol Fa Re# La Sol Do La Fa Do Re Do La La La La R...
output:
445252
result:
ok single line: '445252'
Test #6:
score: 0
Accepted
time: 577ms
memory: 38416kb
input:
9000013 Do# Sol# Do Do# Re# Do# Re# Re# Fa# Fa# Fa Re# Sol# Fa Re# Re# Do# Do Do Re# Re# Fa Fa# La# Do# Fa# Fa# Sol# Sol# Re# Re# Do# La# Fa Fa Do Mi Re Re Sol Mi Re Re La Sol Sol Sol Fa Do Do Si Fa Do Re Si Sol Do Si La Mi La# Re La# Sol La# Re Do Do La Sol Re Do Fa La# La# Mi Sol La# Fa La Mi La D...
output:
247816
result:
ok single line: '247816'
Test #7:
score: 0
Accepted
time: 566ms
memory: 38476kb
input:
9000062 Sol# Fa Do Sol Do Re La# Do Do La# Do Sol# Do Sol Sol# Fa La# Sol# La# La# Re# La# Re Sol La# Sol# Fa Re Re Fa Sol Re Sol# Fa La# La# La# Do Do Sol# Sol# La# Sol# Do Sol Re# Fa# La# Fa Sol# Re# Do# Sol# Sol# Re# Sol# Fa Re# Sol# Sol# Sol# Si Fa# Re# La# Fa# Re# Si Fa Re# Fa# Fa La# Sol# Si R...
output:
247925
result:
ok single line: '247925'
Test #8:
score: 0
Accepted
time: 550ms
memory: 40712kb
input:
9600000 Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol# L...
output:
4800000
result:
ok single line: '4800000'
Test #9:
score: 0
Accepted
time: 436ms
memory: 38408kb
input:
9000012 La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La La L...
output:
6
result:
ok single line: '6'