zoukankan      html  css  js  c++  java
  • Ubuntu_Gedit配置

    Ubuntu_Gedit配置
    • 为了换Ubuntu的时候能够更加方便,不用再用手重新打一遍代码,丢几个Gedit配置……

    External Tools

    1. gdb compile (F2)

      #!/bin/sh
      fullname=$GEDIT_CURRENT_DOCUMENT_NAME
      name=`echo $fullname | cut -d. -f1`
      g++ -o $name $fullname -g -Wall -Wextra -D LOCAL
      gnome-terminal -x bash -c "gdb $name -silent;echo 'Nobody knows you better than I know...';read"
      
    2. compile (F3)

      #!/bin/sh
      fullname=$GEDIT_CURRENT_DOCUMENT_NAME
      name=`echo $fullname | cut -d. -f1`
      g++ $fullname -o $name -Wall -Wextra -D LOCAL -fsanitize=address
      
    3. run (F4)

      #!/bin/sh
      fullname=$GEDIT_CURRENT_DOCUMENT_NAME
      name=`echo $fullname | cut -d. -f1`
      dir=$GEDIT_CURRENT_DOCUMENT_DIR
      gnome-terminal -x bash -c "time $dir/$name; echo;echo 'Nobody knows you better than I know...';read"
      

    Snippets

    1. fast read (Ctrl+R)

      namespace IO {
      	const int N=1<<20;
      	char buf[N],*l=buf,*r=buf;
      	inline char gc() {
      		if(l==r) r=(l=buf)+fread(buf,1,N,stdin);
      		return *(l++);
      	}
      	inline int read() {
      		int x=0,s=1;
      		char ch=gc();
      		while(!isdigit(ch)) {if(ch=='-') s=-1;ch=gc();}
      		while(isdigit(ch)) {x=x*10+(ch^48);ch=gc();}
      		return x*s;
      	}
      	template <typename T> 
      	inline void read(T &x) {
      		int s=1;x=0;
      		char ch=gc();
      		while(!isdigit(ch)) {if(ch=='-') s=-1;ch=gc();}
      		while(isdigit(ch)) {x=x*10+(ch^48);ch=gc();}
      		x*=s;
      	}
      	inline char readc() {
      		char ch=gc();
      		while(ch<=32) ch=gc();
      		return ch;
      	}
      	inline int reads(char *s) {
      		char *point=s;*point=gc();
      		while(*point<=32) *point=gc();
      		while(*point>32) *(++point)=gc();
      		*point='\0';
      		return point-s;
      	}
      }
      
      • 在单位字符串长度大于 \(30\) 的时候,scanf 的效率会高于 reads

      • ch>32 貌似比 isalnum(ch)ch!=' '&&ch!='\n' 要快一点。

        ——测试 on 2021.2.22 17:07

    2. fast basic code (Tab:include,Ctrl+B)

      #include <iostream>
      #include <cstdio>
      
      namespace IO {
      	const int N=1<<20;
      	char buf[N],*l=buf,*r=buf;
      	inline char gc() {
      		if(l==r) r=(l=buf)+fread(buf,1,N,stdin);
      		return *(l++);
      	}
      	inline int read() {
      		int x=0,s=1;
      		char ch=gc();
      		while(!isdigit(ch)) {if(ch=='-') s=-1;ch=gc();}
      		while(isdigit(ch)) {x=x*10+(ch^48);ch=gc();}
      		return x*s;
      	}
      }
      
      using namespace std;
      using IO::read;
      
      int main() {
      #ifdef LOCAL
      	freopen("c.in","r",stdin);
      	//freopen("c.out","w",stdout);
      #endif
      	$0
      	return 0;
      }
      
      // by pycr
      
    3. read (Ctrl+Shift+R)

      inline int read() {
      	int x=0,s=1;
      	char ch=getchar();
      	while(ch<'0'||ch>'9') {if(ch=='-') s=-1;ch=getchar();}
      	while(ch>='0'&&ch<='9') {x=x*10+(ch^48);ch=getchar();}
      	return x*s;
      }
      
    4. basic code (Ctrl+Shift+B)

      #include <iostream>
      #include <cstdio>
      
      using namespace std;
      
      inline int read() {
      	int x=0,s=1;
      	char ch=getchar();
      	while(ch<'0'||ch>'9') {if(ch=='-') s=-1;ch=getchar();}
      	while(ch>='0'&&ch<='9') {x=x*10+(ch^48);ch=getchar();}
      	return x*s;
      }
      
      int main() {
      #ifdef LOCAL
      	freopen("c.in","r",stdin);
      	//freopen("c.out","w",stdout);
      #endif
      	$0
      	return 0;
      }
      
      // by pycr
      
    5. test code (Tab:test)

      #include <iostream>
      #include <cstdio>
      
      using namespace std;
      
      inline int read() {
      	int x=0,s=1;
      	char ch=getchar();
      	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
      	while(isdigit(ch)) {x=x*10+(ch^48);ch=getchar();}
      	return x*s;
      }
      
      int main() {
      #ifdef LOCAL
      	freopen("c.in","r",stdin);
      #else
      	freopen("$1.in","r",stdin);
      	freopen("$2.out","w",stdout);
      #endif
      	$0
      	return 0;
      }
      

    对拍

    RANDOM.cpp

    int n=random(1e5)+1;			//随机生成整数序列
    int m=1e9;
    for(int i=1;i<=n;i++) {
    	seq[i]=random(2*m+1)-m;
    }
    
    
    for(int i=1;i<=n;i++) {			//随机生成区间
    	int l=random(m+1);
    	int r=random(m+1);
    	if(l>r) swap(l,r);
    	printf("%d %d\n",l,r);
    }
    
    
    for(int i=2;i<=n;i++) {			//随机生成树
    	int f=random(i-1)+1;
    	int val=random(1e9)+1;
    	printf("%d %d %d\n",f,i,val);
    }
    

    CHECK.cpp

    #include <cstdio>
    #include <iostream>
    #include <ctime>
    
    using namespace std;
    
    int main() {
    	int cnt=0;bool pass=true;
    #if 1
    	printf("Compiling...\n\n");
    	system("g++ MINE.cpp -o SOL");
    	system("g++ ANS.cpp -o ANS");
    	system("g++ RANDOM.cpp -o RANDOM");
    	printf("Compiled successfully!\n\n");
    #endif
    	while(cnt<1000) {
    		system("./RANDOM");
    		double mine_start=clock();
    		system("./MINE");//system("time ./MINE");
    		double mine_end=clock();
    		double ans_start=mine_end;
    		system("./ANS");//system("time ./ANS");
    		double ans_end=clock();
    		double mine_time=(mine_end-mine_start);
    		double ans_time=(ans_end-ans_start);
    		if(system("diff MINE.out ANS.out")) {
    			printf("Case:%d Wrong Answer!\n\n",++cnt);
    			pass=false;
    			break;
    		}
    		else printf("Case:%d Accept!\nMINE_TIME: %.3lfms\nANS_TIME: %.3lfms\n\n",++cnt,mine_time,ans_time);
    	}
    	if(pass) cout<<"Congratulations!!!"<<endl;
    	else cout<<"What a pity..."<<endl;
    	return 0;	
    }
    
    靡不有初,鲜克有终
  • 相关阅读:
    KVC
    MRC&ARC
    网络基础
    沙盒
    GCD深入了解
    iOS 架构模式MVVM
    iOS 源代码管理工具之SVN
    iOS给UIimage添加圆角的两种方式
    Objective-C 中,atomic原子性一定是安全的吗?
    iOS Block循环引用
  • 原文地址:https://www.cnblogs.com/pycr/p/14278870.html
Copyright © 2011-2022 走看看