QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#239802#5511. Minor Evilelkernos#WA 362ms3908kbC++232.4kb2023-11-04 23:28:452023-11-04 23:28:46

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 23:28:46]
  • 评测
  • 测评结果:WA
  • 用时:362ms
  • 内存:3908kb
  • [2023-11-04 23:28:45]
  • 提交

answer

//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef XOX
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;

void solve(){
    int n, k; cin >> n >> k;
    vector<T>a(k);
    for (int i = 0; i<k; i++){
        cin >> a[i].first >> a[i].second;
    }
    int s; cin >> s;
    vector<bool>bad(n+1);
    for (int i = 0; i<s; i++){
        int x; cin >> x;
        bad[x] = 1;
    }
    vector<int>kill(n+1, -1);
    for (int i = k-1; i>=0 ;i--){
        if (!bad[a[i].first] && bad[a[i].second] && kill[a[i].second] == -1){
            kill[a[i].second] = i;
        }
    }
    for (int i = k-1; i>=0; i--){
        if (!bad[a[i].first]) continue;
        if (!bad[a[i].second]) continue;
        if (kill[a[i].first] >= i && kill[a[i].second] == -1){
            kill[a[i].second] = i;
        }
    }
    bool ok = 1;
    for (int i = 1; i<=n; i++){
        if (bad[i] && kill[i] == -1){
            cout << "NIE\n";
            return;
        }
    }
    cout << "TAK\n";
    vector<bool>where(k);
    for (int i = 0; i<n; i++){
        if (kill[i] != -1){
            where[kill[i]] = 1;
        }
    }
    for (int i = 0; i<k; i++) {
        cout << (where[i] ? "T" : "N");
    }
    cout << "\n";
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) solve();

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3408kb

input:

2
5 6
1 2
2 1
2 5
2 3
2 4
4 2
3
1 2 3
3 2
1 2
2 3
2
2 3

output:

TAK
NTNTNT
NIE

result:

ok correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 362ms
memory: 3908kb

input:

1000
5 6
1 2
2 1
2 5
2 3
2 4
4 2
3
1 2 3
3 2
1 2
2 3
2
2 3
2 1
1 2
1
1
2 1
1 2
1
2
3 3
2 1
3 2
3 2
1
3
3 3
1 3
1 3
1 2
2
1 3
3 3
1 2
1 3
1 3
1
2
3 3
2 1
2 3
1 3
1
2
3 3
3 2
3 1
1 2
3
1 2 3
3 3
1 2
2 3
1 2
1
3
3 3
2 1
1 2
1 2
1
2
3 3
2 1
1 3
1 3
1
1
3 3
3 2
3 2
2 3
1
3
3 3
3 2
1 2
2 1
1
1
3 3
2 1
3 2...

output:

TAK
NTNTNT
NIE
NIE
TAK
N
NIE
NIE
TAK
TNN
NIE
NIE
TAK
NNN
TAK
NNT
TAK
TNN
TAK
NNN
TAK
NNT
TAK
NNT
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
NTNN
TAK
NNTN
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
TNTN
TAK
NNTN
TAK
NNNT
TAK
NNTN
NIE
TAK
NNTN
NIE
NIE
TAK
NNNT
NIE
TAK
NNNN
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
NNT
NI...

result:

wrong answer Some poeple who should be dead are alive. (test case 4)