QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100283#4996. Icy ItineraryjoesmittyWA 2ms3472kbC++203.8kb2023-04-25 14:32:452023-04-25 14:32:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-25 14:32:45]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3472kb
  • [2023-04-25 14:32:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
 
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)
#define all(a) a.begin(), a.end()
#define endl '\n';
#define sz(x) (int)(x).size()
 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
template <typename T>
void pr(vector<T> &v) {
    FOR(i, 0, sz(v)) cout << v[i] << " ";
    cout << endl;
}
template <typename T>
void pr(vector<vector<T> > &v) {
    FOR(i, 0, sz(v)) { pr(v[i]); }
}
template <typename T>
void re(T &x) {
    cin >> x;
}
template <typename T>
void re(vector<T> &a) {
    FOR(i, 0, sz(a)) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &... rest) {
    re(first);
    re(rest...);
}
template <typename T>
void pr(T x) {
    cout << x << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &... rest) {
    cout << first << " ";
    pr(rest...);
    cout << endl;
}
void ps() { cout << endl; }
template<class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
    cout << t; if (sizeof...(ts)) cout << " "; ps(ts...);
}
 
const ll MOD  =  998244353;
#define inf 1e18;
#define INF INT_MAX

long double PI = 4*atan(1);
long double eps = 1e-12;

int nxt[300010] = {};
int pre[300010] = {};
set<pii> conn;

int t(int u, int v) {
    return (conn.count({u,v}) ? 1 : 0);
}
int main() {
    auto start = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);cin.tie(0);
    // ofstream cout("disrupt.out");
    // ifstream cin("disrupt.in");
    #ifdef DEBUG
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif  

    ll n,m; cin >> n >> m;
    FOR(i,0,m) {
        int u,v; cin >> u >> v;
        conn.insert({v,u});
        conn.insert({u,v});
    }

    nxt[1] = 2;
    pre[2] = 1;

    int a = 1;
    int b = 2;
    FOR(i,3,n+1) {
        int x = t(a,b);
        int t1 = t(a,i);
        int t2 = t(b,i);
        if(t1 == x && t2 == x) {
            nxt[a] = i; pre[i] = a;
            nxt[i] = b; pre[b] = i;
            a = i;
        }
        else if(t1 != x && t2 != x) {
            nxt[a] = i; pre[i] = a;
            nxt[i] = b; pre[b] = i;
            if(pre[a] != 0) {
                a = pre[a];
                b = nxt[a];
            } else {
                while(nxt[nxt[a]] != 0) {
                    a = nxt[a];
                }
                b = nxt[a];
            }
        } else if(t1 == x && t2 != x) {
            nxt[a] = i; pre[i] = a;
            nxt[i] = b; pre[b] = i;
            b = i;
        } else if(t1 != x && t2 == x) {
            nxt[b] = i; pre[i] = b;
            if(nxt[b] == 0) {
                a = b;
                b = i;
            } else {
                int c = nxt[b];
                int t3 = t(c, i);
                nxt[i] = c; pre[c] = i;
                if(t3 == x) {
                    a = i; b = c;
                } else {
                    a = b; b = i;
                }
            }
        }
    }   

    int c = 1;
    FOR(i,0,n) {
        cout << c << " ";
        c = nxt[c];
    }
    cout << endl;



    
    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    // cout << duration.count() << endl;
    //cin.close();
    //cout.close();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3384kb

input:

4 4
1 2
1 3
1 4
3 4

output:

1 4 3 2 

result:

ok qwq

Test #2:

score: 0
Accepted
time: 2ms
memory: 3344kb

input:

5 0

output:

1 3 4 5 2 

result:

ok qwq

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3472kb

input:

10 10
7 8
7 5
5 2
6 1
10 7
4 6
5 8
3 2
10 5
1 10

output:

1 4 5 6 7 3 8 9 10 8 

result:

wrong answer Visited the same node multiple times