답안 #254059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254059 2020-07-29T09:38:44 Z amiratou Tenis (COI19_tenis) C++14
0 / 100
500 ms 24440 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[3][100005],pos[100005][3],n;
multiset<int> adj[100005];
bitset<100005> vis;
void gimme(int node){
    vis[node]=1;
    for(auto it:adj[node])
        if(!vis[it])gimme(it);
}
int32_t main(){
    boost;
    //freopen(".in","r",stdin);
    int q,x,t,a,b;
    cin>>n>>q;
    for (int i = 0; i < 3; ++i){
        for (int j = 0; j < n; ++j){
            cin>>tab[i][j],pos[tab[i][j]][i]=j;
            if(j)adj[tab[i][j-1]].insert(tab[i][j]);
        }
    }
    while(q--){
        cin>>t;
        if(t==1){
            cin>>x;
            for (int i = 1; i <= n; ++i)
                vis[i]=0;
            gimme(x);
            bool f=1;
            for (int i = 1; i <= n; ++i)
                if(!vis[i]){f=0;break;}
            if(f)cout<<"DA\n";
            else cout<<"NE\n";
        }
        else{
            cin>>x>>a>>b;
            x--;
            if(pos[a][x]){
                adj[tab[x][pos[a][x]-1]].erase(adj[tab[x][pos[a][x]-1]].find(a));
                adj[tab[x][pos[a][x]-1]].insert(b);
            }
            if(pos[a][x]!=(n-1)){
                adj[a].erase(adj[a].find(tab[x][pos[a][x]+1]));
                adj[b].insert(tab[x][pos[a][x]+1]);  
            }
            if(pos[b][x]){
                adj[tab[x][pos[b][x]-1]].erase(adj[tab[x][pos[b][x]-1]].find(b));
                adj[tab[x][pos[b][x]-1]].insert(a);
            }
            if(pos[b][x]!=(n-1)){
                adj[b].erase(adj[b].find(tab[x][pos[b][x]+1]));
                adj[a].insert(tab[x][pos[b][x]+1]);
            }
            swap(tab[x][pos[a][x]],tab[x][pos[b][x]]);
            swap(pos[a][x],pos[b][x]);
        }
    }
    return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5120 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Runtime error 11 ms 10240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5120 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Runtime error 11 ms 10240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5120 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Runtime error 11 ms 10240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1100 ms 24440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5120 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Runtime error 11 ms 10240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -