Submission #167299

# Submission time Handle Problem Language Result Execution time Memory
167299 2019-12-07T08:42:41 Z theStaticMind Tenis (COI19_tenis) C++14
7 / 100
500 ms 9052 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<vector<int>> data(3,vector<int>(100005));
vector<vector<int>> arr(3);
vector<int> P(3,0);
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,q;
      cin>>n>>q;
      for(int k=0;k<3;k++)
      for(int i=0;i<n;i++){
            int x;
            cin>>x;
            arr[k].pb(x);
            data[k][x]=i;
            if(i==0)P[k]=x;
      }
      while(q--){
            int k;
            cin>>k;
            if(k==1){
                  int x;
                  cin>>x;
                  set<int>cnt;
                  queue<int>Q;
                  cnt.insert(x);
                  Q.push(x);
                  while(!Q.empty()){
                        int w=Q.front();
                        Q.pop();
                        for(k=0;k<3;k++){
                              for(int j=data[k][w]+1;j<n;j++){
                                    if(cnt.count(arr[k][j]))continue;
                                    else{
                                          cnt.insert(arr[k][j]);
                                          Q.push(arr[k][j]);
                                    }
                              }
                        }
                  }
                  if(cnt.size()==n)cout<<"DA\n";
                  else cout<<"NE\n";
            }
            else{
                  int p,x,y;
                  cin>>p>>x>>y;p--;
                  swap(arr[p][data[p][x]],arr[p][data[p][y]]);
                  if(P[p]==x)P[p]=y;
                  else if(P[p]==y)P[p]=x;
                  swap(data[p][x],data[p][y]);
            }
      }

}

Compilation message

tenis.cpp: In function 'int32_t main()':
tenis.cpp:52:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                   if(cnt.size()==n)cout<<"DA\n";
                      ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 3 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 5 ms 3452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 3 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 5 ms 3452 KB Output is correct
7 Correct 249 ms 3448 KB Output is correct
8 Correct 72 ms 3448 KB Output is correct
9 Execution timed out 558 ms 3448 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 3 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 5 ms 3452 KB Output is correct
7 Correct 249 ms 3448 KB Output is correct
8 Correct 72 ms 3448 KB Output is correct
9 Execution timed out 558 ms 3448 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 3 ms 3448 KB Output is correct
4 Correct 5 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 5 ms 3452 KB Output is correct
7 Correct 249 ms 3448 KB Output is correct
8 Correct 72 ms 3448 KB Output is correct
9 Execution timed out 558 ms 3448 KB Time limit exceeded
10 Halted 0 ms 0 KB -