QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133289 | #1774. Customs Controls | ttest | WA | 1ms | 3856kb | C++14 | 1.6kb | 2023-08-01 22:11:12 | 2023-08-01 22:11:15 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define pii pair<int,int>
using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;
int ans[maxn];
bool p[maxn];
bool q[maxn];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T;
memset(ans,-1,sizeof(ans));
while(T--) {
int n,m,k;
cin>>n>>m>>k;
bool rev=false,ok=true;
if(n-k>k) {
rev=true;
k=n-k;
}
for(int i=1;i<=n;i++) {
int x;
cin>>x;
}
for(int i=1;i<=m;i++) {
int x,y;
cin>>x>>y;
if(x>y) {
swap(x,y);
}
if(x==1) {
p[y]=true;
}
if(y==n) {
q[x]=true;
}
}
auto get=[&](int i) {
if(!k) {
ans[i]=true;
} else {
k--;
ans[i]=false;
}
};
if(n==2) {
if(k==1) {
ok=false;
} else {
for(int i=1;i<=n;i++) {
get(i);
}
}
} else if(p[n]) {
get(1);
get(n);
for(int i=2;i<=n-1;i++) {
get(i);
}
} else {
int sum=1;
for(int i=1;i<=n;i++) {
sum+=p[i]&&!q[i];
}
if(sum<=k) {
get(1);
for(int i=1;i<=n;i++) {
if(p[i]&&!q[i]) {
get(i);
}
}
} else {
get(n);
for(int i=1;i<=n;i++) {
if(q[i]&&!p[i]) {
get(i);
}
}
}
for(int i=1;i<=n;i++) {
if(ans[i]==-1) {
get(i);
}
}
}
if(!ok) {
cout<<"impossible\n";
} else {
for(int i=1;i<=n;i++) {
cout<<(ans[i]^rev?'S':'N');
}
cout<<"\n";
}
for(int i=1;i<=n;i++) {
p[i]=q[i]=false;
ans[i]=-1;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3856kb
input:
5 10 2 1 1 1 1 1 3 4 5 4 3 1 4 1 3 5 2 1 2 4 2 5 1 5 2 3
output:
result:
wrong output format Unexpected end of file - token expected