結果
| 問題 | No.1021 Children in Classrooms |
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2020-11-12 15:08:25 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,643 bytes |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 33,920 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 19:11:03 |
| 合計ジャッジ時間 | 2,770 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
main.c: In function 'putrange':
main.c:62:9: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
62 | memcpy(wp,a[st],len);
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy'
+++ |+#include <string.h>
1 | #pragma GCC optimize("Ofast")
main.c:62:9: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
62 | memcpy(wp,a[st],len);
| ^~~~~~
main.c:62:9: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c: At top level:
main.c:66:1: warning: return type defaults to 'int' [-Wimplicit-int]
66 | main(){
| ^~~~
main.c: In function 'main':
main.c:109:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
109 | write(1,wbuf,wp-wbuf);
| ^~~~~
main.c:110:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
110 | _exit(0);
| ^~~~~
| _Exit
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
char wbuf[7*200000+100];
char* putzeros(char*wp,int n){
while(n>0){
*(long*)wp=0x2030203020302030l;
wp+=8;
n-=4;
}
return wp+(n+n);
}
char* putint(char*wp,int v){
if(v>=100000000){
{
int v1=v/100000000;
int n=0;
int a=0;
while(a=a<<8|v1%10|0x30,++n,v1/=10);
*(int*)wp=a;
wp+=n;
}
{
int n=8;
long a=0;
while(a=a<<8|v%10|0x30,v/=10,--n);
*(long*)wp=a;
wp+=8;
}
}else{
int n=0;
long a=0;
while(a=a<<8|v%10|0x30,++n,v/=10);
*(long*)wp=a;
wp+=n;
}
*wp++=0x20;
return wp;
}
char* a[200001];
char* putsum(char*wp,int st,int en){
char*rp=a[st];
int s=0;
for(en-=st;en--;){
int v=0;
int c;
while(c=*rp++-48,c>=0)v=v*10+c;
s+=v;
}
return putint(wp,s);
}
char* putrange(char*wp,int st,int en){
int len=a[en]-a[st];
memcpy(wp,a[st],len);
return wp+len;
}
main(){
char*rp=mmap(0l,7l*2+6l*200000+200001+2,1,2,0,0ll);
RD(n);
while(*rp++!=10);
for(int i=0;i<n;++i){
a[i]=rp;
while(*rp++>=48);
}
a[n]=rp;
char*wp=wbuf;
int x=0,x0=0,x1=0;
int c;
while(c=*rp++,c!=10){
if(c=='L'){
if(x1<++x) x1=x;
}else{
if(x0>--x) x0=x;
}
if(x1-x0==n-1){
goto l1;
}
}
wp=putzeros(wp,x1-x);
wp=putsum(wp,0,x1+1);
wp=putrange(wp,x1+1,n+x0-1);
wp=putsum(wp,n+x0-1,n);
wp=putzeros(wp,x-x0);
goto l2;
l1:;
x=x1-x;
while(c=*rp++,c!=10){
if(c=='L'){
if(--x<0) x=0;
}else{
if(++x>n-1) x=n-1;
}
}
wp=putzeros(wp,x);
wp=putsum(wp,0,n);
wp=putzeros(wp,n-x-1);
l2:
write(1,wbuf,wp-wbuf);
_exit(0);
}
tails