QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#828190#6141. 图函数hamsterball100 ✓70ms7152kbC++141.6kb2024-12-23 14:28:142024-12-23 14:28:15

Judging History

你现在查看的是最新测评结果

  • [2024-12-23 14:28:15]
  • 评测
  • 测评结果:100
  • 用时:70ms
  • 内存:7152kb
  • [2024-12-23 14:28:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAXN=1e3+1;
const int MAXM=2e5+3;
int n,m,ans[MAXM],cnt;
pii e[MAXM];
struct Dynamic_Graph
{
    bitset<MAXN> vis[2][MAXN],g[MAXN];
    Dynamic_Graph *rev;
    inline void init()
    {
        for(int i=1;i<=n;i++)
            vis[0][i].set(i),vis[1][i].set(i),g[i].set(i);
    }
    inline void bfs(int s,int t)
    {
        static queue<int> q;
        static bitset<MAXN> tmp;
        q.push(t);
        while(!q.empty())
        {
            int u=q.front();
            q.pop();
            tmp=g[u]&~vis[0][s];
            for(int v=tmp._Find_next(s-1);v<=n;v=tmp._Find_next(v))
                vis[0][s].set(v),vis[1][v].set(s),cnt+=rev->vis[0][s][v],q.push(v);
        }
    }
    inline void add(int s,int t)
    {
        static bitset<MAXN> tmp;
        g[s].set(t);
        tmp=vis[1][s]&~vis[1][t];
        for(int i=tmp._Find_first();i<=t;i=tmp._Find_next(i))
            vis[0][i].set(t),vis[1][t].set(i),cnt+=rev->vis[0][i][t],bfs(i,t);
    }
} nor,rev;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",&e[i].first,&e[i].second);
    nor.rev=&rev,rev.rev=&nor;
    ans[m]=cnt=n;
    nor.init(),rev.init();
    for(int i=m;i>=1;i--)
    {
        nor.add(e[i].first,e[i].second);
        rev.add(e[i].second,e[i].first);
        // for(int j=1;j<=n;j++)
        //     ans[i-1]+=(nor.vis[0][j]&rev.vis[0][j]).count();
        ans[i-1]=cnt;
    }
    for(int i=0;i<=m;i++)
        printf("%d ",ans[i]);
    return 0;
}

详细


Pretests


Final Tests

Test #1:

score: 4
Accepted
time: 0ms
memory: 6360kb

input:

9 10
5 6
8 6
6 8
8 5
7 8
7 4
6 9
9 7
5 8
3 7

output:

16 16 10 10 9 9 9 9 9 9 9 

result:

ok 11 numbers

Test #2:

score: 4
Accepted
time: 1ms
memory: 4484kb

input:

9 10
7 5
8 5
7 6
7 8
5 6
8 9
5 8
9 3
4 6
1 2

output:

10 10 9 9 9 9 9 9 9 9 9 

result:

ok 11 numbers

Test #3:

score: 4
Accepted
time: 1ms
memory: 4516kb

input:

9 10
6 8
8 4
7 4
6 5
8 7
4 9
4 5
3 8
2 7
4 1

output:

9 9 9 9 9 9 9 9 9 9 9 

result:

ok 11 numbers

Test #4:

score: 4
Accepted
time: 1ms
memory: 4520kb

input:

9 10
7 8
8 4
9 8
6 7
8 7
7 4
5 3
7 6
3 9
9 6

output:

12 10 10 10 9 9 9 9 9 9 9 

result:

ok 11 numbers

Test #5:

score: 4
Accepted
time: 2ms
memory: 6876kb

input:

100 2000
90 74
94 64
88 79
71 93
50 84
85 51
64 50
54 91
78 65
56 94
88 76
79 97
93 59
58 50
98 58
57 66
71 99
61 52
58 54
84 53
69 80
99 95
85 86
77 73
65 66
93 66
86 64
56 77
91 76
96 97
57 80
89 85
75 93
69 63
92 68
59 84
83 93
90 89
84 63
63 97
67 60
59 78
87 97
89 60
50 55
76 69
91 62
73 86
84 ...

output:

5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 5043 ...

result:

ok 2001 numbers

Test #6:

score: 4
Accepted
time: 2ms
memory: 6232kb

input:

100 2000
55 88
54 96
65 72
74 85
57 54
81 67
86 100
81 80
96 84
77 96
65 77
84 70
71 87
59 52
55 90
56 66
86 99
97 96
65 91
54 90
70 74
50 99
97 61
61 99
74 83
84 83
78 59
91 67
77 59
94 57
98 56
80 95
85 92
53 92
82 66
65 74
76 88
56 77
95 90
73 60
96 77
68 60
77 95
61 62
91 59
66 73
57 98
85 52
79...

output:

4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 4963 ...

result:

ok 2001 numbers

Test #7:

score: 4
Accepted
time: 1ms
memory: 4836kb

input:

100 2000
93 59
54 50
63 77
81 73
93 70
74 99
78 72
94 65
64 65
97 89
66 89
60 70
66 67
73 91
72 50
88 79
94 91
97 88
77 59
100 90
63 74
72 95
95 96
59 98
91 94
73 75
54 81
59 94
87 88
67 53
90 81
69 59
50 89
50 90
75 51
66 78
86 76
98 58
85 77
76 90
90 70
75 86
60 74
81 65
51 91
53 62
55 87
65 83
56...

output:

5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 5050 ...

result:

ok 2001 numbers

Test #8:

score: 4
Accepted
time: 0ms
memory: 4556kb

input:

100 2000
97 65
72 70
51 73
77 98
68 89
90 94
92 51
73 55
93 92
73 77
67 71
95 79
63 65
56 84
81 63
98 52
95 94
73 85
67 61
75 82
59 83
81 86
58 94
77 63
70 80
62 73
68 80
77 93
93 68
82 66
55 88
89 51
87 86
96 77
95 57
62 80
50 71
57 59
95 61
97 55
56 94
61 52
74 81
69 99
67 77
72 86
65 62
78 65
93 ...

output:

5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 5046 ...

result:

ok 2001 numbers

Test #9:

score: 4
Accepted
time: 2ms
memory: 6328kb

input:

100 2000
100 90
76 58
77 54
87 98
93 53
83 65
52 88
80 59
75 78
89 82
93 69
90 63
93 64
70 51
85 53
91 85
64 54
76 64
52 84
61 90
95 62
54 88
50 63
60 83
51 55
69 82
77 79
96 55
99 75
61 94
75 96
57 90
50 52
90 99
88 67
75 89
87 88
52 68
63 53
93 54
71 95
79 76
64 52
52 63
71 91
86 70
89 65
78 82
51...

output:

5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 5037 ...

result:

ok 2001 numbers

Test #10:

score: 4
Accepted
time: 1ms
memory: 5984kb

input:

100 2000
69 68
73 83
56 84
52 89
69 79
55 51
98 67
78 94
65 59
66 90
54 69
62 70
96 86
69 85
89 64
55 53
88 67
52 71
77 61
50 86
85 98
66 87
72 91
69 97
80 61
65 90
67 89
50 98
82 79
54 88
96 61
66 54
89 96
65 62
63 61
86 69
62 65
84 53
96 72
53 74
71 50
97 84
51 54
54 76
62 84
62 82
92 65
70 96
67 ...

output:

5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 5047 ...

result:

ok 2001 numbers

Test #11:

score: 4
Accepted
time: 1ms
memory: 4788kb

input:

100 2000
77 50
98 86
78 75
71 96
54 63
82 93
100 79
69 90
50 94
58 79
69 97
73 82
60 92
77 63
69 76
83 71
91 96
97 68
51 91
100 96
58 91
78 60
51 85
68 69
98 80
59 64
59 89
82 67
79 97
90 70
67 60
77 79
63 91
95 62
52 59
56 54
70 66
62 91
88 78
97 94
54 64
78 86
80 68
81 85
88 59
55 51
63 54
60 96
9...

output:

5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5044 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 5041 ...

result:

ok 2001 numbers

Test #12:

score: 4
Accepted
time: 22ms
memory: 4544kb

input:

1000 5000
905 943
790 715
607 668
535 755
686 922
697 791
731 595
831 588
539 770
989 991
539 962
898 973
803 988
600 663
803 836
885 622
969 635
979 927
844 706
660 873
541 574
665 666
620 983
795 635
737 769
566 847
840 542
910 565
798 787
799 781
919 989
754 735
791 736
698 625
614 588
926 764
64...

output:

291786 291773 291773 291773 291773 291773 291773 291773 291773 291773 291214 291214 291085 291085 291085 291085 291085 291085 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290916 290703 290703 290703 290703 290703 290703 290703...

result:

ok 5001 numbers

Test #13:

score: 4
Accepted
time: 25ms
memory: 4632kb

input:

1000 5000
603 764
606 994
894 505
873 843
623 920
888 665
951 974
790 728
838 748
868 941
804 996
678 800
848 825
535 992
855 544
742 794
619 871
705 729
651 811
575 607
813 721
560 541
544 629
678 976
725 755
521 799
867 601
800 521
776 607
833 625
760 521
743 629
705 795
922 699
957 780
768 589
86...

output:

286547 286547 286547 286547 286547 286547 286547 286539 286539 286539 286493 286493 286493 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286258 286126 286126 286126 286126 286126 286126...

result:

ok 5001 numbers

Test #14:

score: 4
Accepted
time: 26ms
memory: 4516kb

input:

1000 5000
540 757
834 936
708 544
630 800
643 571
695 579
607 723
822 549
704 967
630 952
994 587
896 842
716 925
716 516
995 524
692 562
603 653
823 919
582 889
962 568
716 571
971 906
896 639
709 979
568 716
858 767
775 805
931 848
803 820
865 632
655 924
505 913
766 769
961 752
833 705
662 736
85...

output:

294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294157 294013 294013 294013 294013 293795 293795 293795 293795 293795 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692 293692...

result:

ok 5001 numbers

Test #15:

score: 4
Accepted
time: 23ms
memory: 4856kb

input:

1000 5000
933 789
991 747
914 673
551 968
592 656
581 530
663 975
580 544
830 721
665 730
899 863
713 850
887 910
967 608
712 983
621 568
869 840
887 569
580 767
753 606
756 823
711 757
711 979
774 962
976 751
994 549
576 874
597 835
879 837
774 529
875 951
885 821
724 517
569 895
936 789
900 893
82...

output:

297672 297672 297672 297672 297672 297672 297672 297672 297672 297672 297672 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297658 297427 297427 297427 297303 297303 297303 297303 297303...

result:

ok 5001 numbers

Test #16:

score: 4
Accepted
time: 26ms
memory: 4540kb

input:

1000 5000
626 976
941 728
775 831
915 953
776 855
584 811
978 584
988 544
804 605
670 909
570 973
830 738
802 645
995 559
580 996
685 821
636 999
758 862
605 621
784 909
699 633
554 676
962 683
731 993
929 518
991 659
647 819
868 812
532 963
582 930
836 974
695 994
663 832
899 892
718 900
518 547
63...

output:

296057 296057 296057 296057 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295615 295484 295484 295484 295484 295484 295484 295484 295484 295484...

result:

ok 5001 numbers

Test #17:

score: 4
Accepted
time: 23ms
memory: 6612kb

input:

1000 5000
668 513
937 608
953 977
690 790
911 533
937 709
765 932
769 617
662 778
674 597
571 590
830 770
593 810
971 844
746 611
913 688
616 682
911 884
715 964
966 943
847 861
647 699
704 635
885 789
634 585
965 803
671 618
592 506
974 842
664 792
949 819
525 656
670 737
918 909
565 545
502 585
50...

output:

299470 299470 299470 299470 299470 299470 299470 299470 299470 299470 299470 299470 299470 299470 299405 299405 299405 299405 299405 299405 299392 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026 299026...

result:

ok 5001 numbers

Test #18:

score: 4
Accepted
time: 25ms
memory: 5844kb

input:

1000 5000
626 532
632 942
790 556
585 820
759 735
875 980
668 823
594 760
754 903
944 880
739 706
834 928
660 664
993 595
895 924
537 594
659 501
675 831
659 594
708 541
740 560
937 558
575 872
658 721
626 939
977 640
998 819
919 818
886 962
884 794
835 989
904 995
860 899
639 927
613 608
999 994
65...

output:

272036 272036 272036 272036 272036 272036 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271944 271841 271841 271841 271841 271841 271817 271817 271817 271817 271817 271817 271817 271809 271809 271809...

result:

ok 5001 numbers

Test #19:

score: 4
Accepted
time: 26ms
memory: 6612kb

input:

1000 5000
689 841
672 786
924 892
678 851
514 677
639 801
545 541
609 566
523 561
948 628
762 563
755 717
676 732
879 909
878 880
868 869
753 731
965 970
736 622
512 719
661 636
505 656
985 911
545 880
778 502
847 754
627 617
598 922
820 773
873 996
662 871
910 940
741 996
897 791
572 569
587 980
72...

output:

301018 301018 301018 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300887 300771 300771 300771 300771 300771 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767 300767...

result:

ok 5001 numbers

Test #20:

score: 4
Accepted
time: 22ms
memory: 4824kb

input:

1000 5000
733 816
863 904
505 962
533 646
576 621
871 919
707 754
607 806
791 928
877 606
820 563
905 606
551 948
636 835
797 902
792 747
511 654
929 558
619 925
888 848
726 722
962 621
690 653
653 645
615 754
964 766
992 762
939 511
798 870
683 625
828 979
888 609
512 991
604 630
948 562
864 504
93...

output:

295731 295731 295645 295645 295645 295645 295645 295645 295645 295645 295645 295645 295645 295645 295645 295588 295492 295492 295492 295492 295184 295184 295184 295184 295184 295184 295184 294942 294942 294942 294942 294942 294942 294942 294942 294942 294942 294823 294823 294823 294823 294823 294823...

result:

ok 5001 numbers

Test #21:

score: 4
Accepted
time: 69ms
memory: 7128kb

input:

1000 200000
884 638
924 664
659 694
933 743
648 710
649 607
532 636
676 658
860 507
684 722
813 755
600 796
556 822
545 566
742 859
698 526
818 877
573 771
892 511
899 827
981 762
763 633
945 517
544 734
595 739
920 933
937 771
964 769
758 699
592 849
671 900
842 931
560 843
640 643
511 545
742 570
...

output:

500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493 500493...

result:

ok 200001 numbers

Test #22:

score: 4
Accepted
time: 69ms
memory: 6928kb

input:

1000 200000
999 845
729 887
917 705
785 899
982 567
644 679
976 906
587 972
503 683
574 668
718 780
850 515
964 509
516 755
582 872
860 926
881 699
839 527
692 938
602 592
879 692
604 615
651 900
878 625
503 509
869 991
655 975
795 870
673 652
597 687
947 704
731 845
942 560
880 783
686 773
529 962
...

output:

500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492 500492...

result:

ok 200001 numbers

Test #23:

score: 4
Accepted
time: 70ms
memory: 7152kb

input:

1000 200000
789 585
849 970
831 881
746 900
919 924
578 867
685 578
660 580
720 621
519 596
793 552
640 717
664 573
592 985
948 872
589 778
521 584
821 808
589 561
554 683
925 882
624 986
662 818
638 869
603 585
871 887
951 600
883 836
610 890
955 959
852 705
798 738
867 762
925 751
527 890
623 555
...

output:

500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496 500496...

result:

ok 200001 numbers

Test #24:

score: 4
Accepted
time: 70ms
memory: 6848kb

input:

1000 200000
570 523
696 848
926 732
529 621
827 522
977 842
716 577
972 761
934 666
876 873
797 577
744 864
834 690
706 931
975 886
560 946
727 541
634 651
517 921
879 692
848 898
784 872
782 915
641 883
500 697
881 807
679 505
834 616
985 830
529 561
969 574
818 830
888 722
872 714
511 590
674 581
...

output:

500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498 500498...

result:

ok 200001 numbers

Test #25:

score: 4
Accepted
time: 66ms
memory: 6912kb

input:

1000 200000
796 847
597 862
955 623
870 557
903 838
924 577
526 554
990 593
573 565
580 755
654 971
662 831
690 901
747 687
854 589
531 982
593 837
718 664
560 639
774 633
640 982
897 802
928 829
770 564
901 795
723 605
741 547
745 843
716 964
927 720
937 669
616 717
824 950
811 631
605 601
506 933
...

output:

500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500 500500...

result:

ok 200001 numbers

Extra Test:

score: 0
Extra Test Passed