QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790901 | #9726. AUS | Linx# | WA | 0ms | 3940kb | C++17 | 1.5kb | 2024-11-28 15:56:42 | 2024-11-28 15:56:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void solve() {
int n, k;
cin >> n >> k;
int maxn = 0;
std::vector<pii> a(k + 1);
for(int i = 1; i <= k; i ++ ) {
cin >> a[i].first >> a[i].second;
maxn = max(maxn, a[i].second - a[i].first + 1);
}
int cnt = 0;
int l = 0, r = 0;
vector<int> f(n + 1);
vector<int> hi(n + 1);
for(int i = 1; i <= k; i ++ ) {
if(a[i].second - a[i].first + 1 == maxn) {
cnt ++ ;
l = a[i].first, r = a[i].second;
f[l] = 0;
for(int j = l + 1; j <= r; j ++ ) {
f[j] = j - 1;
}
for(int i = 1; i <= r - l; i ++ ) {
hi[i] = r - i;
}
}
if(cnt > 1) {
cout << "IMPOSSIBLE";
return ;
}
}
for(int i = 1; i <= k; i ++ ) {
if(a[i].first != l && a[i].second != r) {
for(int j = a[i].first + 1; j <= a[i].second; j ++ ) {
f[j] = j - 1;
}
f[a[i].first] = hi[a[i].second - a[i].first + 1];
}
}
for(int i = 1; i <= n; i ++ ) {
cout << f[i] << ' ';
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while(t -- ) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3940kb
input:
4 abab cdcd abce abab cdcd abcd abab cdcd abc x yz def
output:
IMPOSSIBLEIMPOSSIBLEIMPOSSIBLEIMPOSSIBLE
result:
wrong answer 1st lines differ - expected: 'YES', found: 'IMPOSSIBLEIMPOSSIBLEIMPOSSIBLEIMPOSSIBLE'