답안 #902632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902632 2024-01-10T21:22:23 Z simona1230 Inside information (BOI21_servers) C++17
10 / 100
1629 ms 64908 KB
#include <bits/stdc++.h>

using namespace std;

int n,k;
int in[4001][4001];

void slow()
{
    for(int i=1;i<=n;i++)
        in[i][i]=1;
    for(int i=1;i<=n+k-1;i++)
    {
        char c;
        cin>>c;
        int x,y;
        if(c=='S')
        {
            cin>>x>>y;
            for(int j=1;j<=n;j++)
            {
                in[x][j]=in[y][j]=max(in[x][j],in[y][j]);
            }
        }
        if(c=='C')
        {
            cin>>x;
            int cnt=0;
            for(int j=1;j<=n;j++)
                cnt+=in[j][x];
            cout<<cnt<<endl;
        }
        if(c=='Q')
        {
            cin>>x>>y;
            if(in[x][y])cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
}


int t[120001];
void subt2()
{
    t[1]=1;
    int sec=2;
    for(int i=1;i<=n+k-1;i++)
    {
        char c;
        cin>>c;

        if(c=='S')
        {
            int x,y;
            cin>>x>>y;

            t[max(x,y)]=sec++;
        }

        if(c=='Q')
        {
            int x,y;
            cin>>x>>y;

            if(t[y]&&t[y]<=t[x]||x==1&&t[y]||y==1&&t[x]||x==y)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }

        if(c=='C')
        {
            int x;
            cin>>x;

            if(t[x]==0)cout<<1<<endl;
            else if(x==1)cout<<sec-1<<endl;
            else cout<<sec-t[x]+1<<endl;
        }
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin>>n>>k;
	if(n<=4000)slow();
    else subt2();

	return 0;
}

Compilation message

servers.cpp: In function 'void subt2()':
servers.cpp:66:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   66 |             if(t[y]&&t[y]<=t[x]||x==1&&t[y]||y==1&&t[x]||x==y)cout<<"yes"<<endl;
      |                ~~~~^~~~~~~~~~~~
servers.cpp:66:50: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   66 |             if(t[y]&&t[y]<=t[x]||x==1&&t[y]||y==1&&t[x]||x==y)cout<<"yes"<<endl;
      |                                              ~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 2756 KB Output is correct
2 Correct 201 ms 64660 KB Output is correct
3 Correct 173 ms 64848 KB Output is correct
4 Correct 205 ms 64836 KB Output is correct
5 Correct 190 ms 64880 KB Output is correct
6 Correct 199 ms 64908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 2756 KB Output is correct
2 Correct 201 ms 64660 KB Output is correct
3 Correct 173 ms 64848 KB Output is correct
4 Correct 205 ms 64836 KB Output is correct
5 Correct 190 ms 64880 KB Output is correct
6 Correct 199 ms 64908 KB Output is correct
7 Correct 168 ms 3320 KB Output is correct
8 Correct 1609 ms 64520 KB Output is correct
9 Correct 539 ms 64620 KB Output is correct
10 Correct 1589 ms 64452 KB Output is correct
11 Correct 1629 ms 64292 KB Output is correct
12 Correct 351 ms 64592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 2644 KB Output is correct
2 Correct 167 ms 3356 KB Output is correct
3 Correct 174 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 2644 KB Output is correct
2 Correct 167 ms 3356 KB Output is correct
3 Correct 174 ms 2896 KB Output is correct
4 Correct 157 ms 2844 KB Output is correct
5 Correct 198 ms 2900 KB Output is correct
6 Correct 153 ms 3328 KB Output is correct
7 Correct 155 ms 3152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 2840 KB Output is correct
2 Incorrect 164 ms 5368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 2840 KB Output is correct
2 Incorrect 164 ms 5368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 2848 KB Output is correct
2 Incorrect 174 ms 5192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 143 ms 2848 KB Output is correct
2 Incorrect 174 ms 5192 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 165 ms 2828 KB Output is correct
2 Incorrect 183 ms 5480 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 165 ms 2828 KB Output is correct
2 Incorrect 183 ms 5480 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 149 ms 2640 KB Output is correct
2 Correct 204 ms 64692 KB Output is correct
3 Correct 200 ms 64852 KB Output is correct
4 Correct 182 ms 64776 KB Output is correct
5 Correct 183 ms 64660 KB Output is correct
6 Correct 189 ms 64848 KB Output is correct
7 Correct 182 ms 3412 KB Output is correct
8 Correct 165 ms 4952 KB Output is correct
9 Correct 180 ms 5904 KB Output is correct
10 Correct 143 ms 3680 KB Output is correct
11 Incorrect 170 ms 6380 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 149 ms 2640 KB Output is correct
2 Correct 204 ms 64692 KB Output is correct
3 Correct 200 ms 64852 KB Output is correct
4 Correct 182 ms 64776 KB Output is correct
5 Correct 183 ms 64660 KB Output is correct
6 Correct 189 ms 64848 KB Output is correct
7 Correct 182 ms 3412 KB Output is correct
8 Correct 165 ms 4952 KB Output is correct
9 Correct 180 ms 5904 KB Output is correct
10 Correct 143 ms 3680 KB Output is correct
11 Incorrect 170 ms 6380 KB Output isn't correct
12 Halted 0 ms 0 KB -