Submission #750540

# Submission time Handle Problem Language Result Execution time Memory
750540 2023-05-29T16:41:33 Z edogawa_something Inside information (BOI21_servers) C++17
5 / 100
1162 ms 35420 KB
#include<bits/stdc++.h>
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef bool bl;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
#define ordered_set tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie();
#define test ll qqqqq;cin>>qqqqq;while(qqqqq--)
#define test1 ll qqqqq=1;while(qqqqq--)
#define F first
#define S second
#define forn(i,n) for(int i=0;i<n;i++)
#define forx(i,j,n) for(int i=j;i<n;i++)
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define pow powww
#define prtll(x) printf("%lld",x)
#define prtld(x) printf("%Lf",x)
#define prtst(x) printf("%s",x)
#define prtch(x) printf("%c",x)
#define measure chrono::high_resolution_clock::now()
#define duration chrono::duration_cast<chrono::milliseconds>(end-start)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const ll dx[]{1,0,-1,0,1,-1,1,-1};
const ll dy[]{0,-1,0,1,1,-1,-1,1};
const ll inf=1e18;
const ll mod=1e9+7;
const ll LM=1e8+1;
const ll M=2e5+10;
const ll MM=4002;
const ll MMM=501;
const ld pi=acos(-1);
//const ll mod=998244353;
ll pow(ll r,ll to,ll m=mod){
  ll res=1;
  r%=m;
  while(to){
    if((to&1)){
      res*=r,res%=m;
    }
    r*=r,r%=m;
    to=(to>>1);
  }
  return res;
}
ll n,k,cnt[M];
bl cur[MM][MM];
int main(){
  fast
  //freopen("gen.txt","r",stdin);
  auto start=measure;
  test1{
    cin>>n>>k;
    forn(i,n+1)
    cur[i][i]=1,cnt[i]=1;
    forn(i,n+k-1){
      char c;
      cin>>c;
      if(c=='S'){
        ll a,b;
        cin>>a>>b;
        set<ll>v;
        forn(i,n+1){
          if(cur[a][i])
          v.insert(i),cnt[i]--;
        }
        forn(i,n+1){
          if(cur[b][i])
          v.insert(i),cnt[i]--;
        }
        for(auto it:v)
        cur[a][it]=cur[b][it]=1,cnt[it]+=2;
      }
      else if(c=='C'){
        ll d;
        cin>>d;
        cout<<cnt[d]<<'\n';
      }
      else if(c=='Q'){
        ll a,b;
        cin>>a>>b;
        if(cur[a][b])
        cout<<"yes\n";
        else
        cout<<"no\n";
      }
    }
  }
  auto end=measure;
  auto dur=duration;
  //cout<<fixed<<dur.count()<<'\n';
  return 0;
}
/*
*/
# Verdict Execution time Memory Grader output
1 Correct 172 ms 1012 KB Output is correct
2 Correct 210 ms 16668 KB Output is correct
3 Correct 330 ms 16928 KB Output is correct
4 Correct 211 ms 16792 KB Output is correct
5 Correct 229 ms 16684 KB Output is correct
6 Correct 1162 ms 17000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 1012 KB Output is correct
2 Correct 210 ms 16668 KB Output is correct
3 Correct 330 ms 16928 KB Output is correct
4 Correct 211 ms 16792 KB Output is correct
5 Correct 229 ms 16684 KB Output is correct
6 Correct 1162 ms 17000 KB Output is correct
7 Correct 163 ms 1020 KB Output is correct
8 Correct 205 ms 16532 KB Output is correct
9 Correct 369 ms 16724 KB Output is correct
10 Correct 202 ms 16512 KB Output is correct
11 Correct 222 ms 16492 KB Output is correct
12 Correct 1125 ms 17104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1120 KB Output is correct
2 Runtime error 23 ms 35296 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1120 KB Output is correct
2 Runtime error 23 ms 35296 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 174 ms 1148 KB Output is correct
2 Runtime error 24 ms 35412 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 174 ms 1148 KB Output is correct
2 Runtime error 24 ms 35412 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 1060 KB Output is correct
2 Runtime error 23 ms 35416 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 1060 KB Output is correct
2 Runtime error 23 ms 35416 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 1128 KB Output is correct
2 Runtime error 22 ms 35364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 1128 KB Output is correct
2 Runtime error 22 ms 35364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 760 KB Output is correct
2 Correct 203 ms 16352 KB Output is correct
3 Correct 344 ms 16448 KB Output is correct
4 Correct 224 ms 16336 KB Output is correct
5 Correct 229 ms 16464 KB Output is correct
6 Correct 1157 ms 16616 KB Output is correct
7 Correct 156 ms 784 KB Output is correct
8 Runtime error 23 ms 35420 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 760 KB Output is correct
2 Correct 203 ms 16352 KB Output is correct
3 Correct 344 ms 16448 KB Output is correct
4 Correct 224 ms 16336 KB Output is correct
5 Correct 229 ms 16464 KB Output is correct
6 Correct 1157 ms 16616 KB Output is correct
7 Correct 156 ms 784 KB Output is correct
8 Runtime error 23 ms 35420 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -