QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39002#1265. Total EclipseclaesCompile Error//C++2.0kb2022-07-08 11:22:142022-07-08 11:22:24

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-08 11:22:24]
  • Judged
  • [2022-07-08 11:22:14]
  • Submitted

answer

#include <bits/stdc++.h>
#pragma GCC optimize(2);
using namespace std ;
int n , m ;
struct node
{
	int bh , br ;
} a[100010] ;
int bb[100010] ;
int fir[100010] , nxt[400010] , zx[400010] , bs ;
int fa[100010] ;
int lt = 0 ;
inline bool pd( node a , node b )
{
	return a.br > b.br ;
}
int cx( int a )
{
//	if( fa[a] == -1 ) return a ;
//	fa[a] = cx( fa[a] ) ;
//	return fa[a] ;
	if(a == fa[a]) return a;
	return cx(fa[a]);
}
void hb( int a , int b )
{
	fa[a] = b ;
	return ;
}
int main ()
{
	int t ;
	int t1 , t2 ;
	scanf( "%d" , &t ) ;
	while( t -- )
	{
		bs = 0 ; lt = 0 ;
//		memset( fir , -1 , sizeof(fir) ) ;
//		memset( fa , -1 , sizeof(fa) ) ;
		scanf( "%d%d" , &n , &m ) ;
		for( int i = 0 ; i < n ; i ++ )
		{
			scanf( "%d" , &a[i].br ) ;
			bb[i] = a[i].br ;
			a[i].bh = i ;
			fa[i] = i;
			fir[i] = -1;
		}
//		if(t == 5) puts("1");
		for( int i = 0 ; i < m ; i ++ )
		{
			scanf( "%d%d" , &t1 , &t2 ) ;
			t1 -- ;
			t2 -- ;
			nxt[bs] = fir[t1] ;
			fir[t1] = bs ;
			zx[bs] = t2 ;
			bs ++ ;
			nxt[bs] = fir[t2] ;
			fir[t2] = bs ;
			zx[bs] = t1 ;
			bs ++ ;
		}
		sort( a , a + n , pd ) ;
		long long ans = 0 ;
		for( int i = 0 ; i < n ; i ++ )
		{
//			if(t == 5)
//			{
//				if( i > 80000 ) return 0 ;
//			}
			lt ++ ;
			for( int j = fir[a[i].bh] ; j != -1 ; j = nxt[j] )
			{
				if( bb[zx[j]] < a[i].br ) continue ;
				int f1 = cx(a[i].bh), f2 = cx(zx[j]);
				if( f1 != f2 )
				{
					hb( f1 , f2 ) ;
					lt -- ;
				}
			}
			while( i < n - 1 && a[i + 1].br == a[i].br )
			{
				i ++ ;
				lt ++ ;
				for( int j = fir[a[i].bh] ; j != -1 ; j = nxt[j] )
				{
					if( bb[zx[j]] < a[i].br ) continue ;
					int f1 = cx(a[i].bh) , f2 = cx(zx[j]);
					if( f1 != f2 )
					{
						hb( f1 , f2 ) ;
						lt -- ;
					}
				}
			}
			if( i != n - 1 )
			{
				ans += (long long)lt * ( a[i].br - a[i + 1].br ) ;
			}
			else
			{
				ans += (long long)lt * a[i].br ;
			}
		}
		printf( "%lld\n" , ans ) ;
	}
	return 0 ;
}

詳細信息

answer.code:2:24: error: ‘#pragma GCC optimize’ string is badly formed
    2 | #pragma GCC optimize(2);
      |                        ^
answer.code: In function ‘int main()’:
answer.code:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf( "%d" , &t ) ;
      |         ~~~~~^~~~~~~~~~~~~
answer.code:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf( "%d%d" , &n , &m ) ;
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
answer.code:43:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |                         scanf( "%d" , &a[i].br ) ;
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:52:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |                         scanf( "%d%d" , &t1 , &t2 ) ;
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~