QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407230 | #1102. Guard | bachbeo2007 | 0 | 1ms | 5752kb | C++20 | 2.6kb | 2024-05-08 11:26:07 | 2024-05-08 11:26:07 |
Judging History
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++;
}
if(num==k){
for(int i=1;i<=n;i++) if(!cnt[i]) cout << i << '\n';
return;
}
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];
}
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();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3536kb
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: 10
Accepted
time: 0ms
memory: 5752kb
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:
1 2 3 6 7 11 12 14 15 16 19 20
result:
ok 12 lines
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 5596kb
input:
20 6 100 14 18 1 17 19 1 3 16 1 17 19 1 15 18 1 16 18 1 18 20 1 3 15 1 4 15 1 15 15 1 14 15 1 7 20 1 2 3 1 15 20 1 14 14 1 15 19 1 1 16 1 2 16 1 3 19 1 18 20 1 16 16 1 2 14 1 3 18 1 2 13 1 16 16 1 2 10 1 4 16 1 11 19 1 6 19 1 2 16 1 4 17 1 14 15 1 18 19 1 19 20 1 1 13 1 2 8 1 15 17 1 2 14 1 2 5 1 17...
output:
14 15 16 18 19
result:
wrong answer 1st lines differ - expected: '3', found: '14'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%