QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407229#1102. Guardbachbeo20070 1ms5832kbC++202.6kb2024-05-08 11:24:362024-05-08 11:24:38

Judging History

This is the latest submission verdict.

  • [2024-05-08 11:24:38]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 5832kb
  • [2024-05-08 11:24:36]
  • Submitted

answer

// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
#define mpp make_pair
#define fi first
#define se second
const long long inf=1e18;
const int mod=998244353;
const int maxn=200005;
const int B=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
const int iroot=power(3,mod-2);
const int base=101;

bool check[maxn];
int n,k,m,cnt[maxn],pos[maxn];
vector<pii> p;

void solve(){
    cin >> n >> k >> m;
    for(int i=1;i<=m;i++){
        int l,r,c;cin >> l >> r >> c;
        if(c) p.push_back({l,r});
        else cnt[l]++,cnt[r+1]--;
    }
    int num=0;
    for(int i=1;i<=n;i++){
        cnt[i]+=cnt[i-1];
        if(!cnt[i]) num++;
    }
    for(int i=1;i<=n;i++){
        cnt[i]=!cnt[i];
        if(cnt[i]) pos[i]=i;
        pos[i]+=pos[i-1];
        cnt[i]+=cnt[i-1];
    }
    if(num==k){
        for(int i=1;i<=n;i++) if(!cnt[i]) cout << i << '\n';
        return;
    }
    for(auto [l,r]:p){
        if(cnt[r]-cnt[l-1]==1){
            int x=pos[r]-pos[l-1];
            check[x]=true;
        }
    }
    vector<int> ans;
    for(int i=1;i<=n;i++) if(check[i]) ans.push_back(i);
    if(ans.empty()) cout << -1 << '\n';
    else{
        for(int x:ans) cout << x << '\n';
    }
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int test=1;//cin >> test;
    while(test--) solve();
}


详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 5832kb

input:

20 9 100
1 9 1
11 12 1
3 19 1
10 20 1
6 10 1
3 4 1
7 9 1
10 20 1
3 4 1
1 4 1
2 17 1
1 16 1
11 17 1
2 4 1
9 16 1
1 11 1
2 19 1
4 9 1
7 13 1
1 4 1
2 11 1
17 19 1
5 20 1
3 19 1
4 9 1
9 16 1
2 19 1
10 18 1
3 19 1
3 11 1
11 19 1
10 19 1
19 20 1
16 20 1
1 11 1
1 8 1
3 4 1
2 16 1
11 19 1
17 20 1
4 5 1
3 4 ...

output:

-1

result:

ok single line: '-1'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 5772kb

input:

20 12 20
12 14 1
16 19 1
6 18 1
1 9 1
7 11 1
17 17 0
5 5 0
1 14 1
3 8 1
9 9 0
10 10 0
18 18 0
9 9 0
7 14 1
13 13 0
8 8 0
4 4 0
2 20 1
13 13 0
18 20 1

output:


result:

wrong answer 1st lines differ - expected: '1', found: ''

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%