QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743664 | #2827. Autobiography | OOBMABTRAMS# | WA | 46ms | 30424kb | C++17 | 779b | 2024-11-13 19:44:34 | 2024-11-13 19:44:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1e9;
const int N=1000013;
int n,m;
vector<int>mp[N];
ll cb[N],co[N];
void solve(){
string s;
cin>>s;
s=' '+s;
for(int i=1;i<=m;i++)mp[i].clear(),cb[i]=co[i]=0;
vector<pair<int,int>>eg;
for(int x,y,i=1;i<=m;i++) {
cin>>x>>y;
mp[x].push_back(y),mp[y].push_back(x);
if(s[y]=='b')cb[x]++;else co[x]++;
if(s[x]=='b')cb[y]++;else co[y]++;
eg.emplace_back(x,y),eg.emplace_back(y,x);
}
ll ans=0;
for(auto [x,y]:eg)if(s[x]=='o'&&s[y]=='b') {
ans+=(cb[x]-1)*(co[y]-1);
}
cout<<ans<<'\n';
}
int main() {
int T=1;
ios::sync_with_stdio(false);
while(cin>>n>>m)solve();
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 29680kb
input:
5 4 bbobo 1 3 2 3 3 4 4 5 4 6 bobo 1 2 1 3 1 4 2 3 2 4 3 4 4 0 bobo
output:
2 4 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 46ms
memory: 30424kb
input:
4 4 oobo 2 3 4 1 4 3 3 1 4 3 obob 1 4 2 3 1 2 4 4 obob 3 1 2 3 2 1 1 4 4 3 bboo 2 4 4 1 3 4 4 3 bbbo 1 4 1 3 4 2 4 4 obbo 3 4 2 4 2 3 3 1 4 3 bobo 2 3 4 3 1 4 4 3 obbb 3 4 4 2 1 4 4 5 bobo 4 1 2 1 3 1 4 3 2 4 4 4 obbo 3 4 3 1 2 3 1 4 4 3 bobb 4 2 4 1 2 3 4 3 obbo 3 1 3 2 1 2 4 4 ooob 2 1 3 1 3 4 1 4...
output:
0 2 1 0 0 1 3 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 4 0 0 0 0 0 5 6 0 0 0 3 3 0 5 0 3 0 1 0 0 0 0 4 3 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0 4 1 4 1 0 0 0 1 4 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 5 1 0 0 0 4 0 0 7 0 0 0 0 0 2 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 ...
result:
wrong answer 2nd lines differ - expected: '1', found: '2'