QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875406 | #7181. Graph Cuts | HeyJinhwi# | WA | 9ms | 16172kb | C++14 | 1.9kb | 2025-01-29 18:00:45 | 2025-01-29 18:00:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
map<int,ll> mp[1<<17];
ll valid[1600];
ll calc[1600];
ll cur[1600];
vector<int> a[1<<17];
vector<pair<int,ll>> b[1<<17];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m;cin>>n>>m;
for(int i=0;i<m;i++)
{
int s,t;cin>>s>>t;
if(mp[s][i/64]==0)
{
a[s].push_back(i/64);
}
mp[s][i/64]|=(1<<(i%64));
if(mp[t][i/64]==0)
{
a[t].push_back(i/64);
}
mp[t][i/64]|=(1<<(i%64));
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<a[i].size();j++)
{
int t=a[i][j];
b[i].push_back({t,mp[i][t]});
}
}
for(int i=0;i<=(n-1)/64;i++)valid[i]=-1;
int q;cin>>q;
char x[3]={};
while(q--)
{
cin>>x;
if(x[0]!='?')
{
int v;cin>>v;
for(int i=0;i<b[v].size();i++)
{
int t=b[v][i].first;
ll s=b[v][i].second;
cur[t]^=s;
}
}
else
{
int flag=0;
for(int i=0;i<=(n-1)/64;i++)
{
calc[i]=valid[i]&cur[i];
if(calc[i]!=0)
{
for(int j=0;j<64;j++)
{
if(calc[i]&(1LL<<j))
{
cout<<i*64+j+1<<'\n';
valid[i]^=(1LL<<j);
break;
}
}
flag=1;
break;
}
}
if(flag==0)
{
cout<<"0\n";
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 15908kb
input:
4 5 1 2 1 3 1 4 2 3 2 4 10 + 1 + 2 ? ? ? ? ? - 2 ? ?
output:
2 3 4 5 0 1 0
result:
ok q=10
Test #2:
score: 0
Accepted
time: 2ms
memory: 15936kb
input:
0 0 0
output:
result:
ok q=0
Test #3:
score: 0
Accepted
time: 3ms
memory: 16112kb
input:
0 0 1 ?
output:
0
result:
ok q=1
Test #4:
score: -100
Wrong Answer
time: 9ms
memory: 16172kb
input:
1000 2000 1 50 1 88 331 1 1 352 1 497 2 32 2 282 550 2 989 2 334 3 3 665 4 38 4 69 4 343 4 451 589 4 917 4 89 5 5 162 675 5 681 6 7 22 127 7 7 592 7 672 787 7 8 310 107 9 9 137 184 9 9 244 378 9 446 9 9 658 883 9 65 10 75 10 414 10 10 468 686 10 245 11 269 11 11 386 403 11 493 11 394 12 493 12 565 1...
output:
4 5 6 7 9 12 14 15 17 19 24 25 26 29 30 31 65 67 70 72 73 74 76 77 78 79 84 86 87 88 90 91 93 129 130 132 133 134 137 139 141 144 145 147 148 149 150 152 71 89 155 157 158 159 160 161 162 163 164 165 166 27 167 168 169 170 171 172 173 174 135 175 2 176 177 178 179 180 181 142 182 183 184 185 186 75 ...
result:
wrong answer Edge exists, but not found