Submission #558401

# Submission time Handle Problem Language Result Execution time Memory
558401 2022-05-07T08:55:20 Z Yazan_Alattar Tenis (COI19_tenis) C++14
0 / 100
1 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 1007;
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;

multiset <int> adj[M];
ll n, q, a[5][M], cnt, pos[5][M];
bool vist[M];

void dfs(int node){
    vist[node] = 1; ++cnt;

    for(auto i : adj[node]) if(!vist[i]) dfs(i);
    return;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= 3; ++i){
        for(int j = 1; j <= n; ++j){
            cin >> a[i][j];
            pos[i][a[i][j]] = j;

            if(j > 1) adj[a[i][j - 1]].insert(a[i][j]);
        }
    }

    while(q--){
        int type;
        cin >> type;

        if(type == 1){
            int x;
            cin >> x;

            dfs(x);
            if(cnt == n) cout << "DA\n";
            else cout << "NE\n";

            for(int i = 1; i <= n; ++i) vist[i] = 0; cnt = 0;
        }
        else{
            int x, y, k;
            cin >> k >> x >> y;

            int i = pos[k][x], j = pos[k][y];

            if(i > 1) adj[a[k][i - 1]].erase(adj[a[k][i - 1]].find(a[k][i]));
            if(i < n) adj[a[k][i]].erase(adj[a[k][i]].find(a[k][i + 1]));
            if(j < n) adj[a[k][j]].erase(adj[a[k][j]].find(a[k][j + 1]));
            if(j > 1) adj[a[k][j - 1]].erase(adj[a[k][j - 1]].find(a[k][j]));

            swap(a[k][i], a[k][j]);

            if(i > 1) adj[a[k][i - 1]].insert(a[k][i]);
            if(i < n) adj[a[k][i]].insert(a[k][i + 1]);
            if(j < n) adj[a[k][j]].insert(a[k][j + 1]);
            if(j > 1) adj[a[k][j - 1]].insert(a[k][j]);
        }
    }
    return 0;
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:53:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |             for(int i = 1; i <= n; ++i) vist[i] = 0; cnt = 0;
      |             ^~~
tenis.cpp:53:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   53 |             for(int i = 1; i <= n; ++i) vist[i] = 0; cnt = 0;
      |                                                      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 1 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 1 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 1 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 1 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -