QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#411409 | #6765. Don't Really Like How The Story Ends | xiaole | TL | 30ms | 99296kb | C++23 | 990b | 2024-05-15 13:00:19 | 2024-05-15 13:00:19 |
Judging History
answer
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;using ll = long long;using PLL = pair<ll,ll>;
const ll MAX = 1e18;const ll MIN = -1e18;const ll INF=0x3f3f3f3f;
const ll Q = 2e6+9;const ll MOD = 1e9 + 7;
set<ll> d[Q];ll ans;
bool vis[Q];ll n,m;
ll now=1;
void dfs(ll x){
for(auto i:d[x]){
if(i<now+1) continue;
while(i>=now+1)
{
if(i==now+1){
now++;
dfs(i);
}else{
ans++;
now++;
dfs(now);
}
}
}
}
void solve(){
cin>>n>>m;
memset(vis,0,sizeof vis);
ans=0;now=1;
for (ll i = 0; i <= n; i++) d[i].clear();
for (ll i = 0; i < m; i++)
{
ll o,p;cin>>o>>p;
if(p>o) d[o].insert(p);
}
d[1].insert(n+1);
dfs(1);
cout<<ans<<"\n";
}
int main(){
ios;ll _=1;cin>>_;
while (_--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 30ms
memory: 99296kb
input:
3 2 3 1 1 1 2 2 1 4 1 1 4 4 2 1 2 3 4
output:
0 2 1
result:
ok 3 lines
Test #2:
score: -100
Time Limit Exceeded
input:
117747 3 7 2 1 3 3 1 3 1 1 3 2 1 1 3 1 4 8 2 3 4 3 3 2 4 2 1 3 2 1 4 3 2 4 3 4 2 3 2 2 3 3 1 1 2 5 1 1 2 2 2 2 1 2 2 2 3 7 2 1 1 2 3 3 3 2 1 2 3 3 3 2 4 5 1 2 3 3 4 4 1 4 2 1 3 1 3 2 1 3 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 5 4 2 1 2 5 1 3 3 2 4 7 1 1 2 4 3 2 1 1 1 1 4 2 2 3 5 8 3 3 2 2 4 2 1 4 1...
output:
1 1 1 0 1 1 2 0 0 3 1 2 1 0 3 1 2 0 2 0 0 4 0 0 1 3 1 1 1 0 0 0 1 1 3 1 4 0 2 1 3 1 4 1 0 0 1 4 0 3 2 2 3 2 1 3 0 0 1 1 1 3 2 2 0 0 1 0 0 3 3 0 1 0 1 0 2 4 0 2 2 1 2 1 0 2 2 3 0 1 2 1 2 0 3 2 1 3 1 0 3 0 0 1 1 0 1 0 0 0 0 4 0 1 0 0 1 0 2 1 2 1 0 1 0 0 0 2 0 2 0 2 1 2 1 1 2 2 1 3 0 2 0 1 1 2 1 1 1 1 ...