QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190049#6320. Parallel Processing (Hard)275307894aAC ✓1ms4116kbC++142.4kb2023-09-28 09:09:082023-09-28 09:09:08

Judging History

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

  • [2023-09-28 09:09:08]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4116kb
  • [2023-09-28 09:09:08]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=N*100+5,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
int n;
vector<tuple<int,int,int> > ans;
void Do(int x,int y,int z){ans.emplace_back(x,y,z);}
void Solve(){
	int i,j;scanf("%d",&n);
	int m=1;
	if(n==1){

	}else if(n<=2){
		Do(m+1,m,m+1);Do(2000,2000,2000);Do(2000,2000,2000);Do(2000,2000,2000);
	}else if(n<=4){
		Do(m+1,m,m+1);Do(m+3,m+2,m+3);Do(2000,2000,2000);Do(2000,2000,2000);
		Do(m+2,m+1,m+2);Do(m+3,m+1,m+3);Do(2000,2000,2000);Do(2000,2000,2000);
	}else if(n<=8){
		Do(m+1,m,m+1);Do(m+3,m+2,m+3);Do(m+5,m+4,m+5);Do(m+7,m+6,m+7);
		Do(m+2,m+1,m+2);Do(m+3,m+1,m+3);Do(m+6,m+5,m+6);Do(m+7,m+5,m+7);
		Do(m+4,m+3,m+4);Do(m+5,m+3,m+5);Do(m+6,m+3,m+6);Do(m+7,m+3,m+7);
	}else if(n<=11){
		Do(m+1,m,m+1);Do(m+3,m+2,m+3);Do(m+5,m+4,m+5);Do(m+8,m+7,m+8);
		Do(m+2,m+1,m+2);Do(m+3,m+1,m+3);Do(m+6,m+5,m+6);Do(m+9,m+8,m+9);
		Do(m+4,m+3,m+4);Do(m+5,m+3,m+5);Do(m+6,m+3,m+6);Do(m+10,m+9,m+10);
		Do(m+7,m+6,m+7);Do(m+8,m+6,m+8);Do(m+9,m+6,m+9);Do(m+10,m+6,m+10);
	}else if(n<=13){
		Do(m+1,m,m+1);Do(m+4,m+3,m+4);Do(m+7,m+6,m+7);Do(m+10,m+9,m+10);
		Do(m+2,m+1,m+2);Do(m+5,m+4,m+5);Do(m+8,m+7,m+8);Do(m+11,m+10,m+11);
		Do(m+3,m+2,m+3);Do(m+4,m+2,m+4);Do(m+5,m+2,m+5);Do(m+12,m+11,m+12);
		Do(m+6,m+5,m+6);Do(m+7,m+5,m+7);Do(m+8,m+5,m+8);Do(2000,2000,2000);
		Do(m+9,m+8,m+9);Do(m+10,m+8,m+10);Do(m+11,m+8,m+11);Do(m+12,m+8,m+12);
	}else{
		if((n-2)%5<=1) n=(n-2)/5*5+3;
		else n=(n-2)/5*5+6;
		int x=(n-1)/5+1;
		int R=x+1;
		for(i=1;i<x;i++){
			Do(i+1,i,i+1);
			for(j=1;j<=3;j++){
				Do(R+1,R,R+1);
				R+=4;if(R>=n) R=x+(R-x)%4+1;
			}
		}
		for(i=x+1;i<=n;i+=4){
			if(R<=n&&n%5==3) Do(R+1,R,R+1),R+=4;
			for(j=min(i+3,n);j>=i;j--) Do(j,i-1,j);
		}
		while(ans.size()%4) Do(2000,2000,2000);
	}
	printf("%d\n",ans.size()/4);
	for(auto i:ans){
		int x,y,z;tie(x,y,z)=i;
		printf("%d %d %d\n",x,y,z);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3964kb

input:

17

output:

7
2 1 2
6 5 6
10 9 10
14 13 14
3 2 3
18 17 18
7 6 7
11 10 11
4 3 4
15 14 15
8 7 8
12 11 12
16 15 16
8 4 8
7 4 7
6 4 6
5 4 5
12 8 12
11 8 11
10 8 10
9 8 9
16 12 16
15 12 15
14 12 14
13 12 13
18 16 18
17 16 17
2000 2000 2000

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 4072kb

input:

18

output:

7
2 1 2
6 5 6
10 9 10
14 13 14
3 2 3
18 17 18
7 6 7
11 10 11
4 3 4
15 14 15
8 7 8
12 11 12
16 15 16
8 4 8
7 4 7
6 4 6
5 4 5
12 8 12
11 8 11
10 8 10
9 8 9
16 12 16
15 12 15
14 12 14
13 12 13
18 16 18
17 16 17
2000 2000 2000

result:

ok AC

Test #3:

score: 0
Accepted
time: 0ms
memory: 4032kb

input:

19

output:

8
2 1 2
7 6 7
11 10 11
15 14 15
3 2 3
19 18 19
8 7 8
12 11 12
4 3 4
16 15 16
20 19 20
9 8 9
5 4 5
13 12 13
17 16 17
21 20 21
9 5 9
8 5 8
7 5 7
6 5 6
13 9 13
12 9 12
11 9 11
10 9 10
17 13 17
16 13 16
15 13 15
14 13 14
21 17 21
20 17 20
19 17 19
18 17 18

result:

ok AC

Test #4:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

20

output:

8
2 1 2
7 6 7
11 10 11
15 14 15
3 2 3
19 18 19
8 7 8
12 11 12
4 3 4
16 15 16
20 19 20
9 8 9
5 4 5
13 12 13
17 16 17
21 20 21
9 5 9
8 5 8
7 5 7
6 5 6
13 9 13
12 9 12
11 9 11
10 9 10
17 13 17
16 13 16
15 13 15
14 13 14
21 17 21
20 17 20
19 17 19
18 17 18

result:

ok AC

Test #5:

score: 0
Accepted
time: 0ms
memory: 4024kb

input:

21

output:

8
2 1 2
7 6 7
11 10 11
15 14 15
3 2 3
19 18 19
8 7 8
12 11 12
4 3 4
16 15 16
20 19 20
9 8 9
5 4 5
13 12 13
17 16 17
21 20 21
9 5 9
8 5 8
7 5 7
6 5 6
13 9 13
12 9 12
11 9 11
10 9 10
17 13 17
16 13 16
15 13 15
14 13 14
21 17 21
20 17 20
19 17 19
18 17 18

result:

ok AC

Test #6:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

120

output:

48
2 1 2
27 26 27
31 30 31
35 34 35
3 2 3
39 38 39
43 42 43
47 46 47
4 3 4
51 50 51
55 54 55
59 58 59
5 4 5
63 62 63
67 66 67
71 70 71
6 5 6
75 74 75
79 78 79
83 82 83
7 6 7
87 86 87
91 90 91
95 94 95
8 7 8
99 98 99
103 102 103
107 106 107
9 8 9
111 110 111
115 114 115
119 118 119
10 9 10
28 27 28
3...

result:

ok AC

Test #7:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

421

output:

168
2 1 2
87 86 87
91 90 91
95 94 95
3 2 3
99 98 99
103 102 103
107 106 107
4 3 4
111 110 111
115 114 115
119 118 119
5 4 5
123 122 123
127 126 127
131 130 131
6 5 6
135 134 135
139 138 139
143 142 143
7 6 7
147 146 147
151 150 151
155 154 155
8 7 8
159 158 159
163 162 163
167 166 167
9 8 9
171 170 ...

result:

ok AC

Test #8:

score: 0
Accepted
time: 0ms
memory: 4004kb

input:

464

output:

186
2 1 2
96 95 96
100 99 100
104 103 104
3 2 3
108 107 108
112 111 112
116 115 116
4 3 4
120 119 120
124 123 124
128 127 128
5 4 5
132 131 132
136 135 136
140 139 140
6 5 6
144 143 144
148 147 148
152 151 152
7 6 7
156 155 156
160 159 160
164 163 164
8 7 8
168 167 168
172 171 172
176 175 176
9 8 9
...

result:

ok AC

Test #9:

score: 0
Accepted
time: 0ms
memory: 4116kb

input:

812

output:

325
2 1 2
165 164 165
169 168 169
173 172 173
3 2 3
177 176 177
181 180 181
185 184 185
4 3 4
189 188 189
193 192 193
197 196 197
5 4 5
201 200 201
205 204 205
209 208 209
6 5 6
213 212 213
217 216 217
221 220 221
7 6 7
225 224 225
229 228 229
233 232 233
8 7 8
237 236 237
241 240 241
245 244 245
9 ...

result:

ok AC

Test #10:

score: 0
Accepted
time: 1ms
memory: 4088kb

input:

862

output:

345
2 1 2
175 174 175
179 178 179
183 182 183
3 2 3
187 186 187
191 190 191
195 194 195
4 3 4
199 198 199
203 202 203
207 206 207
5 4 5
211 210 211
215 214 215
219 218 219
6 5 6
223 222 223
227 226 227
231 230 231
7 6 7
235 234 235
239 238 239
243 242 243
8 7 8
247 246 247
251 250 251
255 254 255
9 ...

result:

ok AC

Test #11:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

996

output:

398
2 1 2
202 201 202
206 205 206
210 209 210
3 2 3
214 213 214
218 217 218
222 221 222
4 3 4
226 225 226
230 229 230
234 233 234
5 4 5
238 237 238
242 241 242
246 245 246
6 5 6
250 249 250
254 253 254
258 257 258
7 6 7
262 261 262
266 265 266
270 269 270
8 7 8
274 273 274
278 277 278
282 281 282
9 ...

result:

ok AC

Test #12:

score: 0
Accepted
time: 1ms
memory: 4116kb

input:

997

output:

399
2 1 2
202 201 202
206 205 206
210 209 210
3 2 3
214 213 214
218 217 218
222 221 222
4 3 4
226 225 226
230 229 230
234 233 234
5 4 5
238 237 238
242 241 242
246 245 246
6 5 6
250 249 250
254 253 254
258 257 258
7 6 7
262 261 262
266 265 266
270 269 270
8 7 8
274 273 274
278 277 278
282 281 282
9 ...

result:

ok AC

Test #13:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

998

output:

399
2 1 2
202 201 202
206 205 206
210 209 210
3 2 3
214 213 214
218 217 218
222 221 222
4 3 4
226 225 226
230 229 230
234 233 234
5 4 5
238 237 238
242 241 242
246 245 246
6 5 6
250 249 250
254 253 254
258 257 258
7 6 7
262 261 262
266 265 266
270 269 270
8 7 8
274 273 274
278 277 278
282 281 282
9 ...

result:

ok AC

Test #14:

score: 0
Accepted
time: 1ms
memory: 4084kb

input:

999

output:

400
2 1 2
203 202 203
207 206 207
211 210 211
3 2 3
215 214 215
219 218 219
223 222 223
4 3 4
227 226 227
231 230 231
235 234 235
5 4 5
239 238 239
243 242 243
247 246 247
6 5 6
251 250 251
255 254 255
259 258 259
7 6 7
263 262 263
267 266 267
271 270 271
8 7 8
275 274 275
279 278 279
283 282 283
9 ...

result:

ok AC

Test #15:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

1000

output:

400
2 1 2
203 202 203
207 206 207
211 210 211
3 2 3
215 214 215
219 218 219
223 222 223
4 3 4
227 226 227
231 230 231
235 234 235
5 4 5
239 238 239
243 242 243
247 246 247
6 5 6
251 250 251
255 254 255
259 258 259
7 6 7
263 262 263
267 266 267
271 270 271
8 7 8
275 274 275
279 278 279
283 282 283
9 ...

result:

ok AC