답안 #666191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666191 2022-11-27T17:17:55 Z nolimiya Homework (CEOI22_homework) C++14
100 / 100
315 ms 374692 KB
#include <bits/stdc++.h>
#include <math.h>
//in the name of god,aka allah
//**gray sety orz**
using namespace std;
#define pi pair<int , int>
#define pii pair<long long , pair<long long , long long>>
const int maxm = 2e6 + 5;
const long long mod = 1e9 + 7;
const int SQ = 12;
typedef long long ll;
int l,r,mid;
int n,m;
ll dis[maxm] , sum[maxm];
bool isval(int mid){
    //cout << mid <<" " << mid*mid-mid <<endl;
    if (((mid-1)*mid)/2 < m) return 0;
    return 1;
}
int darage[maxm] , ss , mm;
queue<int> q;
vector<int> g[maxm] , z[maxm];
ll sath[maxm];
bool vis[maxm*SQ] , gos[maxm];
int pedaret[maxm*SQ];
ll get_par(ll v){
    if (pedaret[v]==v) return v;
    return pedaret[v] = get_par(pedaret[v]);
}
ll pars1[maxm] , pars2[maxm];
vector<ll> se[maxm];
set<ll> st,ts;
int rp[maxm] , pr[maxm];
ll dp[maxm*SQ];
pi w[maxm];
int rw[400][400];
int dage[maxm*SQ];
map<ll,ll> mp,pm,f;
priority_queue<pi> lowq;
priority_queue<int, vector<int>, greater<int> > upq;
void solve(int v, int u , int w);
void dfs(int v){
    if (!g[v].size()){ pedaret[v] = darage[v] = sath[v] = 1;
        return;
    }
    auto u=g[v][0], w=g[v][1];
    dfs(u) , dfs(w);
    solve(v,u,w);
    return;
}
void solve(int v,int u, int w){
	sath[v] = sath[u]+sath[w];
    if (vis[v]){
        l = sath[u]-darage[u]+1 , r = sath[u]-(pedaret[u]-1);
        pedaret[u] = l , darage[u] = r;
        l = sath[w]-darage[w]+1 , r = sath[w]-(pedaret[w]-1);
        pedaret[w] = l , darage[w] = r;
    }
    if (vis[v]) swap(u,w);
    darage[v] = sath[v]-(sath[u]-darage[u]+sath[w]-darage[w]+1);
    pedaret[v] = min(pedaret[u],pedaret[w]);
    if (vis[v]) l=sath[v]-darage[v]+1 , r=sath[v]-(pedaret[v]-1) , pedaret[v]=l , darage[v]=r;
    return;
}
vector<int> vec;
void prep(){
	for (int i=1; i<=n; i++) vis[i] = darage[i] = 0;
}
void solve(ll x){
	for (int i=0; i<31; i++){
		if (x&(1<<i)) dp[i]++;
	}
	return ;
}
bool val(int x){
	//cout<<x<<" ";
	if (x>n/2) return 0;
	for (int i=1; i<=x; i++){
		//cout<<x<<" "<<pedaret[n-x+i]<<" "<<pedaret[i]<<endl;
		if (pedaret[n-x+i]-pedaret[i]<m) return 0;
	}
	return 1;
}
string k[maxm],t[maxm];
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s;
    cin >>s;
    vector<int> vec;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='m'){
            if(vec.size()) g[vec.back()].push_back(m);
            vec.push_back(m);
            vis[m]=(s[i+2]=='x'?1:0);
            m++;
            i+=3;
        }
        else if(s[i]==')') vec.pop_back();
        else if(s[i]=='?') g[vec.back()].push_back(m),m++;
    }
    dfs(0) , cout<<darage[0]-pedaret[0]+1<<endl;
}

Compilation message

Main.cpp: In function 'void prep()':
Main.cpp:67:46: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   67 |  for (int i=1; i<=n; i++) vis[i] = darage[i] = 0;
      |                                    ~~~~~~~~~~^~~
Main.cpp: In function 'int main()':
Main.cpp:90:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |     for(int i=0; i<s.size(); i++){
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 266444 KB Output is correct
2 Correct 115 ms 266388 KB Output is correct
3 Correct 134 ms 266392 KB Output is correct
4 Correct 130 ms 266448 KB Output is correct
5 Correct 128 ms 266392 KB Output is correct
6 Correct 125 ms 266492 KB Output is correct
7 Correct 126 ms 266476 KB Output is correct
8 Correct 134 ms 266384 KB Output is correct
9 Correct 120 ms 266444 KB Output is correct
10 Correct 114 ms 266432 KB Output is correct
11 Correct 135 ms 266436 KB Output is correct
12 Correct 123 ms 266392 KB Output is correct
13 Correct 125 ms 266396 KB Output is correct
14 Correct 130 ms 266440 KB Output is correct
15 Correct 116 ms 266440 KB Output is correct
16 Correct 115 ms 266508 KB Output is correct
17 Correct 125 ms 266456 KB Output is correct
18 Correct 119 ms 266480 KB Output is correct
19 Correct 121 ms 266448 KB Output is correct
20 Correct 113 ms 266464 KB Output is correct
21 Correct 124 ms 266444 KB Output is correct
22 Correct 122 ms 266396 KB Output is correct
23 Correct 114 ms 266468 KB Output is correct
24 Correct 133 ms 266480 KB Output is correct
25 Correct 116 ms 266380 KB Output is correct
26 Correct 121 ms 266568 KB Output is correct
27 Correct 118 ms 266452 KB Output is correct
28 Correct 137 ms 266464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 266444 KB Output is correct
2 Correct 115 ms 266388 KB Output is correct
3 Correct 134 ms 266392 KB Output is correct
4 Correct 130 ms 266448 KB Output is correct
5 Correct 128 ms 266392 KB Output is correct
6 Correct 125 ms 266492 KB Output is correct
7 Correct 126 ms 266476 KB Output is correct
8 Correct 134 ms 266384 KB Output is correct
9 Correct 120 ms 266444 KB Output is correct
10 Correct 114 ms 266432 KB Output is correct
11 Correct 135 ms 266436 KB Output is correct
12 Correct 123 ms 266392 KB Output is correct
13 Correct 125 ms 266396 KB Output is correct
14 Correct 130 ms 266440 KB Output is correct
15 Correct 116 ms 266440 KB Output is correct
16 Correct 115 ms 266508 KB Output is correct
17 Correct 125 ms 266456 KB Output is correct
18 Correct 119 ms 266480 KB Output is correct
19 Correct 121 ms 266448 KB Output is correct
20 Correct 113 ms 266464 KB Output is correct
21 Correct 124 ms 266444 KB Output is correct
22 Correct 122 ms 266396 KB Output is correct
23 Correct 114 ms 266468 KB Output is correct
24 Correct 133 ms 266480 KB Output is correct
25 Correct 116 ms 266380 KB Output is correct
26 Correct 121 ms 266568 KB Output is correct
27 Correct 118 ms 266452 KB Output is correct
28 Correct 137 ms 266464 KB Output is correct
29 Correct 116 ms 266392 KB Output is correct
30 Correct 119 ms 266484 KB Output is correct
31 Correct 131 ms 266464 KB Output is correct
32 Correct 120 ms 266452 KB Output is correct
33 Correct 117 ms 266384 KB Output is correct
34 Correct 131 ms 266480 KB Output is correct
35 Correct 123 ms 266468 KB Output is correct
36 Correct 119 ms 266388 KB Output is correct
37 Correct 116 ms 266484 KB Output is correct
38 Correct 116 ms 266404 KB Output is correct
39 Correct 122 ms 266444 KB Output is correct
40 Correct 122 ms 266464 KB Output is correct
41 Correct 115 ms 266444 KB Output is correct
42 Correct 115 ms 266444 KB Output is correct
43 Correct 119 ms 266536 KB Output is correct
44 Correct 120 ms 266568 KB Output is correct
45 Correct 129 ms 266408 KB Output is correct
46 Correct 114 ms 266428 KB Output is correct
47 Correct 120 ms 266448 KB Output is correct
48 Correct 117 ms 266396 KB Output is correct
49 Correct 124 ms 266436 KB Output is correct
50 Correct 116 ms 266440 KB Output is correct
51 Correct 116 ms 266408 KB Output is correct
52 Correct 119 ms 266484 KB Output is correct
53 Correct 120 ms 266396 KB Output is correct
54 Correct 117 ms 266456 KB Output is correct
55 Correct 115 ms 266496 KB Output is correct
56 Correct 119 ms 266436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 372756 KB Output is correct
2 Correct 277 ms 374488 KB Output is correct
3 Correct 287 ms 374692 KB Output is correct
4 Correct 279 ms 374428 KB Output is correct
5 Correct 282 ms 374460 KB Output is correct
6 Correct 280 ms 374472 KB Output is correct
7 Correct 278 ms 374472 KB Output is correct
8 Correct 285 ms 374484 KB Output is correct
9 Correct 275 ms 374616 KB Output is correct
10 Correct 280 ms 374560 KB Output is correct
11 Correct 280 ms 374408 KB Output is correct
12 Correct 278 ms 374436 KB Output is correct
13 Correct 121 ms 266472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 266444 KB Output is correct
2 Correct 115 ms 266388 KB Output is correct
3 Correct 134 ms 266392 KB Output is correct
4 Correct 130 ms 266448 KB Output is correct
5 Correct 128 ms 266392 KB Output is correct
6 Correct 125 ms 266492 KB Output is correct
7 Correct 126 ms 266476 KB Output is correct
8 Correct 134 ms 266384 KB Output is correct
9 Correct 120 ms 266444 KB Output is correct
10 Correct 114 ms 266432 KB Output is correct
11 Correct 135 ms 266436 KB Output is correct
12 Correct 123 ms 266392 KB Output is correct
13 Correct 125 ms 266396 KB Output is correct
14 Correct 130 ms 266440 KB Output is correct
15 Correct 116 ms 266440 KB Output is correct
16 Correct 115 ms 266508 KB Output is correct
17 Correct 125 ms 266456 KB Output is correct
18 Correct 119 ms 266480 KB Output is correct
19 Correct 121 ms 266448 KB Output is correct
20 Correct 113 ms 266464 KB Output is correct
21 Correct 124 ms 266444 KB Output is correct
22 Correct 122 ms 266396 KB Output is correct
23 Correct 114 ms 266468 KB Output is correct
24 Correct 133 ms 266480 KB Output is correct
25 Correct 116 ms 266380 KB Output is correct
26 Correct 121 ms 266568 KB Output is correct
27 Correct 118 ms 266452 KB Output is correct
28 Correct 137 ms 266464 KB Output is correct
29 Correct 116 ms 266392 KB Output is correct
30 Correct 119 ms 266484 KB Output is correct
31 Correct 131 ms 266464 KB Output is correct
32 Correct 120 ms 266452 KB Output is correct
33 Correct 117 ms 266384 KB Output is correct
34 Correct 131 ms 266480 KB Output is correct
35 Correct 123 ms 266468 KB Output is correct
36 Correct 119 ms 266388 KB Output is correct
37 Correct 116 ms 266484 KB Output is correct
38 Correct 116 ms 266404 KB Output is correct
39 Correct 122 ms 266444 KB Output is correct
40 Correct 122 ms 266464 KB Output is correct
41 Correct 115 ms 266444 KB Output is correct
42 Correct 115 ms 266444 KB Output is correct
43 Correct 119 ms 266536 KB Output is correct
44 Correct 120 ms 266568 KB Output is correct
45 Correct 129 ms 266408 KB Output is correct
46 Correct 114 ms 266428 KB Output is correct
47 Correct 120 ms 266448 KB Output is correct
48 Correct 117 ms 266396 KB Output is correct
49 Correct 124 ms 266436 KB Output is correct
50 Correct 116 ms 266440 KB Output is correct
51 Correct 116 ms 266408 KB Output is correct
52 Correct 119 ms 266484 KB Output is correct
53 Correct 120 ms 266396 KB Output is correct
54 Correct 117 ms 266456 KB Output is correct
55 Correct 115 ms 266496 KB Output is correct
56 Correct 119 ms 266436 KB Output is correct
57 Correct 119 ms 266492 KB Output is correct
58 Correct 119 ms 266480 KB Output is correct
59 Correct 124 ms 266576 KB Output is correct
60 Correct 121 ms 266696 KB Output is correct
61 Correct 132 ms 266460 KB Output is correct
62 Correct 118 ms 266536 KB Output is correct
63 Correct 119 ms 266472 KB Output is correct
64 Correct 127 ms 266520 KB Output is correct
65 Correct 135 ms 266532 KB Output is correct
66 Correct 129 ms 266568 KB Output is correct
67 Correct 124 ms 266452 KB Output is correct
68 Correct 126 ms 266460 KB Output is correct
69 Correct 124 ms 266592 KB Output is correct
70 Correct 132 ms 266528 KB Output is correct
71 Correct 133 ms 266548 KB Output is correct
72 Correct 120 ms 266560 KB Output is correct
73 Correct 132 ms 266572 KB Output is correct
74 Correct 126 ms 266516 KB Output is correct
75 Correct 129 ms 266576 KB Output is correct
76 Correct 120 ms 266540 KB Output is correct
77 Correct 123 ms 266604 KB Output is correct
78 Correct 127 ms 266572 KB Output is correct
79 Correct 136 ms 266572 KB Output is correct
80 Correct 119 ms 266500 KB Output is correct
81 Correct 122 ms 266644 KB Output is correct
82 Correct 119 ms 266580 KB Output is correct
83 Correct 122 ms 266508 KB Output is correct
84 Correct 124 ms 266480 KB Output is correct
85 Correct 123 ms 266544 KB Output is correct
86 Correct 121 ms 266424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 266444 KB Output is correct
2 Correct 115 ms 266388 KB Output is correct
3 Correct 134 ms 266392 KB Output is correct
4 Correct 130 ms 266448 KB Output is correct
5 Correct 128 ms 266392 KB Output is correct
6 Correct 125 ms 266492 KB Output is correct
7 Correct 126 ms 266476 KB Output is correct
8 Correct 134 ms 266384 KB Output is correct
9 Correct 120 ms 266444 KB Output is correct
10 Correct 114 ms 266432 KB Output is correct
11 Correct 135 ms 266436 KB Output is correct
12 Correct 123 ms 266392 KB Output is correct
13 Correct 125 ms 266396 KB Output is correct
14 Correct 130 ms 266440 KB Output is correct
15 Correct 116 ms 266440 KB Output is correct
16 Correct 115 ms 266508 KB Output is correct
17 Correct 125 ms 266456 KB Output is correct
18 Correct 119 ms 266480 KB Output is correct
19 Correct 121 ms 266448 KB Output is correct
20 Correct 113 ms 266464 KB Output is correct
21 Correct 124 ms 266444 KB Output is correct
22 Correct 122 ms 266396 KB Output is correct
23 Correct 114 ms 266468 KB Output is correct
24 Correct 133 ms 266480 KB Output is correct
25 Correct 116 ms 266380 KB Output is correct
26 Correct 121 ms 266568 KB Output is correct
27 Correct 118 ms 266452 KB Output is correct
28 Correct 137 ms 266464 KB Output is correct
29 Correct 116 ms 266392 KB Output is correct
30 Correct 119 ms 266484 KB Output is correct
31 Correct 131 ms 266464 KB Output is correct
32 Correct 120 ms 266452 KB Output is correct
33 Correct 117 ms 266384 KB Output is correct
34 Correct 131 ms 266480 KB Output is correct
35 Correct 123 ms 266468 KB Output is correct
36 Correct 119 ms 266388 KB Output is correct
37 Correct 116 ms 266484 KB Output is correct
38 Correct 116 ms 266404 KB Output is correct
39 Correct 122 ms 266444 KB Output is correct
40 Correct 122 ms 266464 KB Output is correct
41 Correct 115 ms 266444 KB Output is correct
42 Correct 115 ms 266444 KB Output is correct
43 Correct 119 ms 266536 KB Output is correct
44 Correct 120 ms 266568 KB Output is correct
45 Correct 129 ms 266408 KB Output is correct
46 Correct 114 ms 266428 KB Output is correct
47 Correct 120 ms 266448 KB Output is correct
48 Correct 117 ms 266396 KB Output is correct
49 Correct 124 ms 266436 KB Output is correct
50 Correct 116 ms 266440 KB Output is correct
51 Correct 116 ms 266408 KB Output is correct
52 Correct 119 ms 266484 KB Output is correct
53 Correct 120 ms 266396 KB Output is correct
54 Correct 117 ms 266456 KB Output is correct
55 Correct 115 ms 266496 KB Output is correct
56 Correct 119 ms 266436 KB Output is correct
57 Correct 290 ms 372756 KB Output is correct
58 Correct 277 ms 374488 KB Output is correct
59 Correct 287 ms 374692 KB Output is correct
60 Correct 279 ms 374428 KB Output is correct
61 Correct 282 ms 374460 KB Output is correct
62 Correct 280 ms 374472 KB Output is correct
63 Correct 278 ms 374472 KB Output is correct
64 Correct 285 ms 374484 KB Output is correct
65 Correct 275 ms 374616 KB Output is correct
66 Correct 280 ms 374560 KB Output is correct
67 Correct 280 ms 374408 KB Output is correct
68 Correct 278 ms 374436 KB Output is correct
69 Correct 121 ms 266472 KB Output is correct
70 Correct 119 ms 266492 KB Output is correct
71 Correct 119 ms 266480 KB Output is correct
72 Correct 124 ms 266576 KB Output is correct
73 Correct 121 ms 266696 KB Output is correct
74 Correct 132 ms 266460 KB Output is correct
75 Correct 118 ms 266536 KB Output is correct
76 Correct 119 ms 266472 KB Output is correct
77 Correct 127 ms 266520 KB Output is correct
78 Correct 135 ms 266532 KB Output is correct
79 Correct 129 ms 266568 KB Output is correct
80 Correct 124 ms 266452 KB Output is correct
81 Correct 126 ms 266460 KB Output is correct
82 Correct 124 ms 266592 KB Output is correct
83 Correct 132 ms 266528 KB Output is correct
84 Correct 133 ms 266548 KB Output is correct
85 Correct 120 ms 266560 KB Output is correct
86 Correct 132 ms 266572 KB Output is correct
87 Correct 126 ms 266516 KB Output is correct
88 Correct 129 ms 266576 KB Output is correct
89 Correct 120 ms 266540 KB Output is correct
90 Correct 123 ms 266604 KB Output is correct
91 Correct 127 ms 266572 KB Output is correct
92 Correct 136 ms 266572 KB Output is correct
93 Correct 119 ms 266500 KB Output is correct
94 Correct 122 ms 266644 KB Output is correct
95 Correct 119 ms 266580 KB Output is correct
96 Correct 122 ms 266508 KB Output is correct
97 Correct 124 ms 266480 KB Output is correct
98 Correct 123 ms 266544 KB Output is correct
99 Correct 121 ms 266424 KB Output is correct
100 Correct 258 ms 339532 KB Output is correct
101 Correct 268 ms 339612 KB Output is correct
102 Correct 255 ms 339676 KB Output is correct
103 Correct 262 ms 339680 KB Output is correct
104 Correct 262 ms 339896 KB Output is correct
105 Correct 290 ms 351416 KB Output is correct
106 Correct 282 ms 351680 KB Output is correct
107 Correct 284 ms 351556 KB Output is correct
108 Correct 281 ms 351464 KB Output is correct
109 Correct 277 ms 351508 KB Output is correct
110 Correct 283 ms 339564 KB Output is correct
111 Correct 315 ms 339656 KB Output is correct
112 Correct 276 ms 339644 KB Output is correct
113 Correct 298 ms 339548 KB Output is correct
114 Correct 272 ms 339736 KB Output is correct
115 Correct 311 ms 374212 KB Output is correct
116 Correct 282 ms 374392 KB Output is correct
117 Correct 289 ms 374292 KB Output is correct
118 Correct 279 ms 374284 KB Output is correct
119 Correct 298 ms 374168 KB Output is correct
120 Correct 270 ms 339364 KB Output is correct
121 Correct 274 ms 339316 KB Output is correct
122 Correct 282 ms 339320 KB Output is correct
123 Correct 274 ms 339388 KB Output is correct
124 Correct 265 ms 357048 KB Output is correct
125 Correct 270 ms 356936 KB Output is correct
126 Correct 278 ms 357100 KB Output is correct
127 Correct 262 ms 356880 KB Output is correct
128 Correct 199 ms 305580 KB Output is correct
129 Correct 199 ms 305484 KB Output is correct
130 Correct 207 ms 305392 KB Output is correct
131 Correct 122 ms 266444 KB Output is correct