QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875408#7181. Graph CutsHeyJinhwi#WA 9ms16324kbC++141.9kb2025-01-29 18:04:332025-01-29 18:04:34

Judging History

This is the latest submission verdict.

  • [2025-01-29 18:04:34]
  • Judged
  • Verdict: WA
  • Time: 9ms
  • Memory: 16324kb
  • [2025-01-29 18:04:33]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
map<int,ll> mp[1<<17];
ll valid[1700];
ll calc[1700];
ll cur[1700];
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/60]==0)
        {
            a[s].push_back(i/60);
        }
        mp[s][i/60]|=(1<<(i%60));

        if(mp[t][i/60]==0)
        {
            a[t].push_back(i/60);
        }
        mp[t][i/60]|=(1<<(i%60));
    }
    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)/60;i++)valid[i]=(1LL<<60)-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)/60;i++)
            {
                calc[i]=valid[i]&cur[i];
                if(calc[i]!=0)
                {
                    for(int j=0;j<60;j++)
                    {
                        if(calc[i]&(1LL<<j))
                        {
                            cout<<i*60+j+1<<'\n';
                            valid[i]^=(1LL<<j);
                            break;
                        }
                    }
                    flag=1;
                    break;
                }
            }
            if(flag==0)
            {
                cout<<"0\n";
            }
        }
    }
}

详细

Test #1:

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

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: 3ms
memory: 15988kb

input:

0 0
0

output:


result:

ok q=0

Test #3:

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

input:

0 0
1
?

output:

0

result:

ok q=1

Test #4:

score: -100
Wrong Answer
time: 9ms
memory: 16324kb

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
63
65
67
70
72
73
74
76
77
78
79
84
86
87
88
89
91
123
124
126
127
128
129
130
132
133
134
137
139
141
144
145
147
148
71
149
152
153
154
155
156
157
158
159
160
161
162
27
163
164
165
166
167
168
169
170
135
171
2
172
173
174
175
176
177
142
178
179
180
184
185
...

result:

wrong answer Edge exists, but not found